Jump to content

[SOLVED] Return result


jaymc

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.