blackberry - WebWorks AJAX Cross domain request -


i'm working on playbook app webworks sdk. i'm trying make http request (method: post) sending , recieving data. can response server, server can't $post data, when try display $_post['apikey'], nothing apears, checked code 100 times, checked config.xml uri, can't find error.

tl;dr: can't send can receive data.

my php server code:

echo "passed key is: ".$_post["apikey"]; // nothing apears echo "<br>";  if(md5($_session['private_key'])===$_post["apikey"]){  }  else{     echo "invalid api key"; // getting response on client app     exit(); } ?> 

my js client code:

function httprequest(){     var key="a984a4474cff54d8468a296edf3af65b"; document.getelementbyid("status").innerhtml="reaching server..."; ////////////////////////////////////// var xdr = getxdomainrequest(); xdr.onload = function() {     document.getelementbyid("status").innerhtml=xdr.responsetext; }  xdr.open("post", "http://mydomain/index.php"); xdr.send("apikey="+key); 

}


solved: when using post method should define request header:

xdr.open("post", "http://mydomain.com/index.php"); xdr.setrequestheader('content-type','application/x-www-form-urlencoded'); // line xdr.send("apikey="+key); 

solved: when using post method should define request header:

xdr.open("post", "http://mydomain.com/index.php"); xdr.setrequestheader('content-type','application/x-www-form-urlencoded'); // line xdr.send("apikey="+key); 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -