weixin_33701251 2011-03-17 00:29 采纳率: 0%
浏览 28

从PHP生成的动态XML

I have a PHP script that loads XML content dynamically:

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; and to ultimately send the result back from the dynamically created XML file. I've been trying to figure this out for hours

Here is the ajax Script

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

Has anybody done something similar to this concept?

  • 写回答

1条回答 默认 最新

  • perhaps? 2011-03-17 00:36
    关注

    Why not pass it as a GET param like so...

    jQuery

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

    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;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog