![](/img/trans.png)
[英]Android Cordova2.3 -jquery ajax($.support.cors = true) not working(same request works on chrome browser)
[英]Posting to IP using ajax not working in Cordova but works fine with phone browser
我正在嘗試在 cordova 中將數據發布到我的計算機 IP(作為 url)。 我可以通過手機訪問 IP,甚至可以使用手機瀏覽器測試 cordova 應用程序。 手機瀏覽器完美運行。 當我在我的 android 手機(Android 9.0)中運行該應用程序時,它會出現錯誤(無法在“XMLHttpRequest”上執行“發送”:無法加載“myIP”。
這是我的代碼;
$.ajax({
url: "http://xxx.xxx.xx.xxx:8000/arat",
data:{
password:password,
studentID:studentID
},
type:'post',
//dataType: 'xml',
async: false,
contentType:"application/x-www-form-urlencoded",
success: function(result){
alert("Data: "+result);
},
error: function(xhr, ajaxOptions, thrownError){
alert("msg: "+thrownError+" , status: "+xhr.status);
}
});
任何幫助將不勝感激。 謝謝你。
這是 SSL 問題,android 9; 必須將 xml:android 添加到小部件,如下所示;
<widget id="my.app.cordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
然后添加添加了以下平台;
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
晚點再謝我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.