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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.