javascript - XMLHttpRequest GET Server Status is 200 but POST Server Status is 500 -


i writing function in javascript post json data using xmlhttprequest post method. following code works fine get:

function httpget(myurl, cb){    var xmlhttp = new xmlhttprequest();    xmlhttp.onreadystatechange=function(){         if (xmlhttp.readystate==4 && xmlhttp.status==200){             if( typeof cb === 'function' )                 cb(xmlhttp.responsetext);         }     };     xmlhttp.open("get",myurl,true);    xmlhttp.send(); } 

however, following code, same url used gives me xmlhttp status of 500 time.

function httppost(myurl,data,cb){      var xmlhttp = new xmlhttprequest();     xmlhttp.onreadystatechange=function(){         if (xmlhttp.readystate == 4 && xmlhttp.status == 200){             if (typeof cb == 'function'){                 cb(xmlhttp.responsetext);             }         } };  xmlhttp.open("post",myurl,true); xmlhttp.setrequestheader("content-type", "application/json"); xmlhttp.send(data); } 


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -