|
我也是醉了,死活跨域不了。浏览器里跨域访问正常的很。
ajax error给的是
SecurityError:Failed toe execute 'open' on 'XMLHttpRequest':Refused to connect to 'http://len/data' because i violates the document's COntent Security Policy.
Cordova5
AndroidManifest.xml加了
<uses-permission android:name="android.permission.INTERNET" />
config.xml
<access origin="*"/>
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
$.ajax({
type: "POST",
crossDomain: true,
dataType: "json",
url: "http://len/data",
cache: false,
async: false,
data:{},
success: function(html){
alert("success ! " + html);
},
error:function(XMLHttpRequest, textStatus, errorThrown){
alert(XMLHttpRequest);
alert(textStatus);
alert(errorThrown);
}
}); |
|