简体   繁体   中英

Dynamic XML Generated from PHP

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?

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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