jaymc Posted June 10, 2008 Share Posted June 10, 2008 I have this function open_url(url, div) { if (window.ActiveXObject) {link = new ActiveXObject("Microsoft.XMLHTTP");} else if (window.XMLHttpRequest) {link = new XMLHttpRequest();} link.onreadystatechange = function() {response(url, div);}} link.open("GET", url + '&ms=' + new Date().getTime(), true); link.send(null); function response(url, div) { if (link.readyState == 4) { if (div == "alert") {alert(link.responseText);} else if (div == "returnit") {return link.responseText;} } } For some reason, the returnin part does not return the content. I want to be able to do this var cheese = open_url("page.php", "returnin"); alert (cheese); The result of that is an alert box that says "undefined" Link to comment https://forums.phpfreaks.com/topic/109558-solved-return-result/ Share on other sites More sharing options...
Psycho Posted June 10, 2008 Share Posted June 10, 2008 I don't have the time to test that out, but this should be the problem: The "div" name in the function call does not match the one you are testing against in the function: var cheese = open_url("page.php", "returnin"); --------------------------------- else if (div == "returnit") {return link.responseText;} Link to comment https://forums.phpfreaks.com/topic/109558-solved-return-result/#findComment-562022 Share on other sites More sharing options...
jaymc Posted June 10, 2008 Author Share Posted June 10, 2008 I don't have the time to test that out, but this should be the problem: The "div" name in the function call does not match the one you are testing against in the function: var cheese = open_url("page.php", "returnin"); --------------------------------- else if (div == "returnit") {return link.responseText;} Sorry, that was a typo It still does not work with the correct value Link to comment https://forums.phpfreaks.com/topic/109558-solved-return-result/#findComment-562151 Share on other sites More sharing options...
Psycho Posted June 10, 2008 Share Posted June 10, 2008 Can you please post a "test" page with all the necessary code to test this? Link to comment https://forums.phpfreaks.com/topic/109558-solved-return-result/#findComment-562212 Share on other sites More sharing options...
jaymc Posted June 10, 2008 Author Share Posted June 10, 2008 Edited Link to comment https://forums.phpfreaks.com/topic/109558-solved-return-result/#findComment-562303 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.