so I've tried this for the entire day but can't seem to solve it.. I have some AJAX getting a JSON string from a PHP script, and now I want to get it into JavaScript.
What I've tried is this:
var xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var obj = jQuery.parseJSON(xmlhttp.responseText);
}
}
xmlhttp.open("GET","back.php?q="+query,true);
xmlhttp.send();
But all I get is
Uncaught SyntaxError: Unexpected token < x.extend.parseJSON xmlhttp.onreadystatechange
I've tried all type of code like
obj = JSON.parse(xmlhttp.responseText);
alert(obj.length);
Whatever I do I basically get the error above.. don't know what to do.. I really wanna solve this with jQuery/JS..
Thanks alot for any help!