javascript - POST array not receiving xhr data with JSON type -


i'm bit puzzled this. want hands via xhr, on client side, on contents of json file server , can't seem manage that.

no jquery, plain xmlhttprequest.

function getjson(user, value) {   params = "user=" + user + "&value=" + value;   request = new ajaxrequest(); //wrapper around xmlhttprequest   request.open("post", "checksj.php", true);     request.setrequestheader("content-type", "application/json");   request.setrequestheader("content-length", params.length);   request.setrequestheader("connection", "close");   request.onload = function() {   var status = request.status;   if (this.readystate == 4)         if (this.status == 200)             if (this.responsetext != null)                 o('contents').innerhtml = this.responsetext;  }  request.send(params); } 

when print_r contents of $_post array empty array although when check out source in firebug parameters values being sent.

any idea on why not working? i'd content working example accomplishes task.

put

request.setrequestheader("content-type","application/x-www-form-urlencoded"); 

remove

request.setrequestheader("content-length", params.length); request.setrequestheader("content-type", "application/json"); 

as not sending json, content-length not needed.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -