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" Quote Link to comment 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;} Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
jaymc Posted June 10, 2008 Author Share Posted June 10, 2008 Edited Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.