Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WebWorks AJAX跨域请求_Ajax_Blackberry_Xmlhttprequest_Blackberry Playbook_Blackberry Webworks - Fatal编程技术网

WebWorks AJAX跨域请求

WebWorks AJAX跨域请求,ajax,blackberry,xmlhttprequest,blackberry-playbook,blackberry-webworks,Ajax,Blackberry,Xmlhttprequest,Blackberry Playbook,Blackberry Webworks,我正在使用WebWorksSDK开发playbook应用程序。 我试图通过发送和接收数据来发出http请求(方法:post)。 我可以从服务器获取响应,但服务器无法获取$POST数据,当我尝试显示$_POST['apiKey']时,没有任何提示,我检查了我的代码100次,检查了我的config.xml的uri,找不到错误 TL;DR:无法发送但可以接收数据 我的PHP服务器代码: echo "passed key is: ".$_POST["apiKey"]; // Nothing apears

我正在使用WebWorksSDK开发playbook应用程序。 我试图通过发送和接收数据来发出http请求(方法:post)。 我可以从服务器获取响应,但服务器无法获取$POST数据,当我尝试显示$_POST['apiKey']时,没有任何提示,我检查了我的代码100次,检查了我的config.xml的uri,找不到错误

TL;DR:无法发送但可以接收数据

我的PHP服务器代码:
echo "passed key is: ".$_POST["apiKey"]; // Nothing apears
echo "<br>";

if(md5($_SESSION['private_key'])===$_POST["apiKey"]){

}

else{
    echo "Invalid API Key"; // Always getting this response on client app
    exit();
}
?>
}


已解决: 使用POST方法时,应定义请求标头:

xdr.open("POST", "http://mydomain.com/index.php");
xdr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); // with this line
xdr.send("apiKey="+key);
xdr.open("POST", "http://mydomain.com/index.php");
xdr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); // with this line
xdr.send("apiKey="+key);

已解决:使用POST方法时,应定义请求标头:

xdr.open("POST", "http://mydomain.com/index.php");
xdr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); // with this line
xdr.send("apiKey="+key);
xdr.open("POST", "http://mydomain.com/index.php");
xdr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); // with this line
xdr.send("apiKey="+key);

你应该回答这个问题,这样它就不会被列为未回答的问题。