I have a cross domain request working perfectly within firefox, chrome etc as soon as i compile with phonegap it stops working
Ajax:
function createCORSRequest(method, url){
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr){
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined"){
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
var request = createCORSRequest("get", "http://www.sellfast.co.za/get.php");
if (request){
request.onload = function(){
document.body.innerHTML = request.responseText;
}
request.send();
}
This code rewrites the body hmtl and just shows the result text fetched from the server. I did this simply for testing. it does nothing once running in phonegap
this is get.php on the server:
<?php
header("Access-Control-Allow-Origin: *");
echo "Hello world";
?>
I added this to the phonegap config.xml:
<access origin="*" subdomains="true" />
But it still didnt change anything
Any idea why this isnt working?
Best Regards,
Jason
在phonegap中使用ajax,您必须将特定域列入白名单,您可以在此处阅读有关其的所有信息, 请单击此处访问页面
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.