I have this code:
var xml = $.ajax({url: "aardvark-ajax.php?rand="+Math.random(),async: false, dataType:'xml'});
alert(xml);
jQuery('image', xml).each(function(i)
{
alert(jQuery(this).text());
});
However, the each loop isn’t working, so I’m guessing my $.ajax query is wrong.
This is the code in aardvark-ajax.php:
$arrImages = array(1,2,3,4);
header('Content-Type: text/xml');
echo '<data>';
echo '<total>' . $intTotal . '</total>';
foreach ($arrImages as $strImage)
{
echo ' <image>' . $strImage . '</image>';
}
echo '</data>';
Thge first alert(xml) outputs [object XMLHttpRequest].
Any ideas?
Try: