Jump to content

AJAX error


lakshmananindia

Recommended Posts

Hai friends,

    I used AJAX for a simple project. In that I used the following statement.

 

xmlHttp.open("POST",edit_company_ajax.php+"?flag="+flag+"&user="+user_id,true);

xmlHttp.send(null);

 

    When I executed this code in my browser it is working fine. But when I executed the same in my friends system I got the following error message.

    ------------------------

    While trying to process the request:

    POST /~lakshmanan/13_deploy/Trainee_FinalProject_2007/lakshmanan_sathishkumar/bin/edit_company_ajax.php?id=1 HTTP/1.1

    Host: 192.168.1.12

    User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070310 Iceweasel/2.0.0.3 (Debian-2.0.0.3-1)

    Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Proxy-Connection: keep-alive

Referer: http://192.168.1.12/~lakshmanan/13_deploy/Trainee_FinalProject_2007/lakshmanan_sathishkumar/bin/Edit_company.php

Cookie: PHPSESSID=334e96eccb310ebe8acc545ea626f122

Pragma: no-cache

Cache-Control: no-cache

The following error was encountered:

* Invalid Request

Some aspect of the HTTP Request is invalid. Possible problems:

* Missing or unknown request method

* Missing URL

* Missing HTTP Identifier (HTTP/1.0)

        * Request is too large

* Content-Length missing for POST or PUT requests

* Illegal character in hostname; underscores are not allowed

-----------------------------------------------------------

Now I changed my code to GET method.

xmlHttp.open("GET",edit_company_ajax.php+"?flag="+flag+"&user="+user_id,true);

xmlHttp.send(null);

 

Now it is working fine in my friends system.

I wanted to know why the problem occurred in my friends system and not in my system and the difference made by the GET and POST in both system?

pls help.

 

 

 

Link to comment
Share on other sites

In POST, you need to send the data, not attach it to the url:

xmlHttp.open("POST",edit_company_ajax.php+"?flag="+flag+"&user="+user_id,true);
xmlHttp.send(null);

To this:

xmlHttp.open("POST","edit_company_ajax.php",true);
xmlHttp.send("flag="+flag+"&user="+user_id);

 

Link to comment
Share on other sites

In POST, you need to send the data, not attach it to the url:

xmlHttp.open("POST",edit_company_ajax.php+"?flag="+flag+"&user="+user_id,true);
xmlHttp.send(null);

To this:

xmlHttp.open("POST","edit_company_ajax.php",true);
xmlHttp.send("flag="+flag+"&user="+user_id);

 

I know this already. But my question is why it differs across systems?

It worked in my system but not in my friends system.

 

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.