View Single Post
Old 06-30-2009, 11:41 AM   #1 (permalink)
Izzmo
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
AJAX responseText undefined

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); }
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline   Reply With Quote