简体   繁体   English

从PHP生成的动态XML

[英]Dynamic XML Generated from PHP

I have a PHP script that loads XML content dynamically: 我有一个PHP脚本,可以动态加载XML内容:

require_once 'directory/directory/';  
$nice= '1149632';  

$key = 'adf995jdfdfddda44rfg';   
$mixer  = new Live_Products($key);  

$result = $mixer->product($nice)  
->show(array('name','Price'))  
->query();

echo $result

This will work fine when it is loaded. 加载后可以正常工作。 But I am trying to use an ajax/jquery script to send the value $nice to the PHP script; 但是我试图使用ajax / jquery脚本将值$ nice发送到PHP脚本; and to ultimately send the result back from the dynamically created XML file. 并最终将结果从动态创建的XML文件发送回去。 I've been trying to figure this out for hours 我已经尝试了好几个小时了

Here is the ajax Script 这是ajax脚本

function sendValues() {  
$("$nice")  
    $.ajax({  
        url: "/myphp.php",  
        data: {str}  
        cache: false  
    });  
}  

Has anybody done something similar to this concept? 有人做过与此概念类似的事情吗?

Why not pass it as a GET param like so... 为什么不像这样将它作为GET参数传递呢?

jQuery jQuery的

function sendValues(something) {  
    $.ajax({  
        url: "/myphp.php?nice=" + something,  
        cache: false,
        dataType: 'xml',
        success: function(xml) {
            // Work with the XML
        }  
    });  
} 

PHP 的PHP

require_once 'directory/directory/';  
$nice= '1149632';  

$key = 'adf995jdfdfddda44rfg';   
$mixer  = new Live_Products($key);  

$result = $mixer->product($_GET['nice'])  
->show(array('name','Price'))  
->query();

// You said it is XML?
header('Content-Type: text/xml');

echo $result;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM