[jQuery] The format of xml response
The following is the interface file:
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$("a").click(function(){
$.post("ajax-post-handler.php",{
name: "John",
address: "123 Main St."
}, function(xml){
alert( $("name",xml).text() );
}
);
return(false);
});
});
</script>
</head>
<body>
<a href="http://jquery.com/">jQuery</a>
<div id="maindiv"></div>
</body>
</html>
The following is the handling file. The above form posts to this file to
handle.
<?php
$name=$_POST['name'];
$address=$_POST['address'];
$returnXML = "<response>
<name>Sachin</name>
<address>Sagar</address>
</response>";
echo $returnXML;
?>
But when the alert is shown, its blank. I couldn't figure out wats
hapenning. I think the problem is reading back the <name> in the XML format
or the
alert( $("name",xml).text() ); syntax.
Is the returning XML is in the correct format?
Is the $("name",xml).text() syntax correct?
Help me out plz.
Thanks
--
View this message in context: http://www.nabble.com/The-format-of-xml-response-tf2138761.html#a5902309
Sent from the JQuery forum at Nabble.com.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/