【发布时间】:2022-08-19 02:07:48
【问题描述】:
当我在 Chrome 浏览器上运行项目时,ajax 请求工作正常,但是当我在 Android 上安装应用程序时,请求不再工作。 这是代码:
var xhr=new XMLHttpRequest()
xhr.onerror=function(){
var message=alert(txt(\'Please turn on mobile data or Wi-Fi\',\'Ligue os dados moveis ou Wi-Fi\'))
}
xhr.onreadystatechange=function (){
if (this.status== 200 && this.readyState == 4){
alert(\"trye\")
eval(xhr.responseText)
}
}
xhr.open(\"POST\",`http://dpreaction.ml?i=js`)
xhr.setRequestHeader(\'Content-type\',\'application/x-www-form-urlencoded\')
xhr.send()
config.xml 文件
<?xml version=\'1.0\' encoding=\'utf-8\'?>
<widget id=\"com.teste.teste\" version=\"1.0.0\" xmlns=\"http://www.w3.org/ns/widgets\" xmlns:cdv=\"http://cordova.apache.org/ns/1.0\">
<name>DP Reaction</name>
<description>Inrease your things</description>
<author email=\"gilluisfrancisco70@gmail.com\" href=\"http://dpreaction.ml\">
DP Reaction
</author>
<content src=\"index.html\" />
<allow-intent href=\"*\" />
<access origin=\"*\" />
<allow-naviation href=\"*\" />
</widget>
这是我的标签:
<meta http-equiv=\"Content-Security-Policy\" content=\"default-src * \'unsafe-inline\' \'unsafe-eval\' data: gap: https://ssl.gstatic.com \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\'; media-src *; img-src \'self\' data: content:;\">
标签: javascript android html cordova cordova-plugins