Jump to content

AJAX unspecified error


maverick5x

Recommended Posts

Hello all

 

i have this function

client = createXMLObject();
	var params = "username="+Username+"&password="+Password;
	client.setRequestHeader("Content-Type", "text/plain");
	client.open("POST","login.php",true);
	client.onreadystatechange = updateLogin;
	client.send(params);

 

and it gives an error in the line where i setRequestHeader "unspecified error".

I am reading a tutorial and this code was in it. so what can be the problem?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/37846-ajax-unspecified-error/
Share on other sites

Thanks to a guy called "Dashiva" in "javascript" channel on some IRC server :P.

 

He pointed out the problem by saying: "Duh, you dont set the header before calling open()" so i moved the header setting to the line just after calling open() method and it worked. Without even using $HTTP_RAW_POST_DATA.

 

here is the result:

client = createXMLObject();
var params = "username="+Username+"&password="+Password;
client.open("POST","login.php",true);
client.setRequestHeader("Content-Type", "application/x-www-form-urlencoded ");
client.onreadystatechange = updateLogin;
client.send(params);

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.