Reputation: 494
I make jQuery Ajax
request which return output in XML
format.
i want to access this XML
in PHP
to Process on data.
Below is sample of my code...
getTime.php File
<?php
header("Content-type: text/xml");
echo '<Dates>';
echo '<Now ';
echo 'val="' . date("h:m:s") . '" ';
echo '/>';
echo '</Dates>';
//echo date("h:m:s");
?>
index.php File
jQuery(document).ready(function(e) {
$('#btnTime').click(function(){
getData("GetTime.php");
});
});
function getData(strUrl)
{
$.ajax({
type: "POST",
url: strUrl,
dataType: "xml",
success: function(output){
// I want to Retrieve this XML Object (output) to PHP
}
});
}
How can I access XML outputed by jQuery in PHP
?
Please help me..
Upvotes: 0
Views: 1877
Reputation: 1095
You need to make another call to your webserver in the success callback.
function getData(strUrl)
{
$.ajax({
type: "POST",
url: strUrl,
dataType: "xml",
success: function(output){
$.ajax({
type: "POST",
url: strUrlToPostXml,
dataType: "xml",
success: function(output){
// Whatever you want, the Xml has been successfully posted back to Php
}
});
}
});
}
But it's quite weird to do that though: it would be much better to have everything done on the server side using the initial call.
Upvotes: 1