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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -