I can't figure out why it does this, any help would be appreciated.
I have a javascript function with will request a php file, get some information from a database, and then pass it back (with JSON) to the browser. Well, ajax sends the information back intact (as you can see from the first alert right after it sends it back), but once it hits the second function, it shows up as 'undefined'. Not sure why it does this.
Code:
// XMLHttp Ajax Object
var xmlhttp;
var responseText = "";
function loadXMLDoc(url)
{
xmlhttp = null;
if (window.XMLHttpRequest)
xmlhttp = new XMLHttpRequest();
else if (window.ActiveXObject)
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp != null)
{
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4)
{
if (xmlhttp.status == 200)
{
alert(xmlhttp.responseText); // comes back with right response
responseText = json_parse(xmlhttp.responseText);
}
else
alert("Problem retrieving XML data");
}
};
xmlhttp.open("GET", url, false);
xmlhttp.send(null);
}
else
alert("Your browser does not support XMLHTTP.");
}
function getData()
{
loadXMLDoc("<?php echo VARS::SITE_ROOT; ?>getModels.php?make="+make+"&year="+year+"&model="+model+"&trim="+trim);
alert(responseText);
}