I've been racking my brain for a couple hours now and doing a lot of searching and I cannot seem to find an answer. I want to know if it is possible to return the xmlhttp.responseText value from an AJAX function to the function that originally called the AJAX function.
// Set handler for server response.
xmlhttp.onreadystatechange = function()
if (xmlhttp.readyState == 4)
if (xmlhttp.status == 200)
var my_response = xmlhttp.responseText;
// How can I return my_response?
I want to return the my_response variable to the original caller. No matter what I try I have been unsuccessful. I even tried assigning it to the global window variable using window.my_response = xmlhttp.responseText but it ends up being undefined.
Every example I've seen of using AJAX pretty much does something inside of the if (xmlhttp.status == 200) part to update the web page. I really do not want to do that.
Can I return the value? Thanks for your help.