lakshmananindia Posted January 21, 2009 Share Posted January 21, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/141738-ajax-error/ Share on other sites More sharing options...
Philip Posted January 21, 2009 Share Posted January 21, 2009 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); Quote Link to comment https://forums.phpfreaks.com/topic/141738-ajax-error/#findComment-742475 Share on other sites More sharing options...
lakshmananindia Posted January 22, 2009 Author Share Posted January 22, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/141738-ajax-error/#findComment-743303 Share on other sites More sharing options...
RichardRotterdam Posted January 22, 2009 Share Posted January 22, 2009 if any error occured it's most likely it wasn't the OS that caused it. It's probably the differences in the javascript engines. If you think it is the OS then try running just the PHP script an both systems you will see it will run the same Quote Link to comment https://forums.phpfreaks.com/topic/141738-ajax-error/#findComment-743382 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.