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
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);

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.