![](/img/trans.png)
[英]I can not get http request to work on android 10 api 29 or api 30. It does work with lower apis though
[英]Cordova - this.http.get() request does not work with API level 31( It was working in API level 30)
我需要你的幫助朋友我遇到的問題 Cordova 10.1.2(。當我在 config.xml 文件中將 API 級別從 30 更改為 31 時:
此代碼無效
$.ajax({url: "#URL"
, type: 'GET'
, async: false
, success: function (result) {
LOGGER.info('result ', result);
}
, complete: function (xhr, status) {
}
});
HTTP 不工作,HTTPS 工作,請幫我工作 HTTP。
我相信,http 支持在 cordova-android-10.0.0 中被刪除,然后在 cordova-android-10.1.0 中恢復。 但是你需要在你的 config.xml 中明確添加它,我相信這是這個偏好(但我不是 100% 確定,如果它不起作用請告訴我,我們還有一些與此相關的其他偏好):
<preference name="scheme" value="http" />
更新文檔(同時查看支持被刪除的文檔,即 10.0.0): https://cordova.apache.org/announcements/2021/08/16/cordova-android-10.1.0.html
順便說一下,如果 https 可以正常工作,為什么要使用 http?
另外,考慮遷移到 fetch-api: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API 。 這是一種更現代的方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.