我知道一个应用程序,我应该用$ .getJSON通过http发送数据。与科尔多瓦的跨域请求
我的问题:当我用铬或其他浏览器测试其通过,但是当我生成的apk和我在手机上测试它没有通过。
我认为这肯定是科尔多瓦的配置的问题(6.4.0版本)
JS
function jsoncallback(data){
alert(data.service+" bien enregistré");
$('#load').show();
$('#imload').hide();
}
function Service(service) {
var var1 =$('#var1').val();
var var2 =$('#var2').val();
if(var1 == 0 || var2 == 0){
alert('Service impossible.. ');
}else{
if(confirm("Choix : "+var1+" | "+var2)){
$('#load').hide();
$('#imload').show();
$.getJSON("http://xxxx.xxxx.xx/service.php?var1="+var1+"&var2="+var2+"&jsoncallback=?");
}
}
}
的Config.xml
<access origin="*" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
[http://stackoverflow.com/questions/30060534/ajax-requests -fail-后升级到科尔多瓦-5-0-科尔多瓦-android4-0](http://stackoverflow.com/questions/30060534/ajax-requests-fail-after-upgrading-to-cordova-5- 0-cordova-android4-0) –