For some reason, the answer to this problem is completely eluding me. I've written two Javascript functions - one needs to get the return value from the other. For some reason though, the first function seems to always be getting an 'undefined' error. Here's the setup:
Code: Select all
function main_nav_clean(id)
{
var working_element = document.getElementById(id);
var new_text = document.getElementById('new_text').value;
var new_href = document.getElementById('new_href').value;
var update_status = 'default';
update_status = getXMLHTTP('/common/update_main_nav.php?id=' + id + '&text=' + new_text + '&href=' + new_href);
alert(update_status);
}Code: Select all
function getXMLHTTP(url_to_send)
{
...
xmlhttp.open("e;GET"e;, url_to_send, true);
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{
var ret_val = xmlhttp.responseText;
return(ret_val);
}
}
}