这是两个页面,test.php和testserver.php.
test.php的
<script src="scripts/jq.js" type="text/javascript"></script>
<script>
$(function() {
$.ajax({url:"testserver.php",
success:function() {
alert("Success");
},
error:function() {
alert("Error");
},
dataType:"json",
type:"get"
}
)})
</script>
Run Code Online (Sandbox Code Playgroud)
testserver.php
<?php
$arr = array("element1",
"element2",
array("element31","element32"));
$arr['name'] = "response";
echo json_encode($arr);
?>
Run Code Online (Sandbox Code Playgroud)
现在我的问题是:当这两个文件都在同一台服务器(localhost或web服务器)上时,它可以工作并被alert("Success")调用; 如果它位于不同的服务器上,意味着Web服务器上的testserver.php和localhost上的test.php,它就无法工作,并且alert("Error")正在执行.即使ajax中的URL更改为http://domain.com/path/to/file/testserver.php
我一直在读Adobe已经在flash 9-10中使crossdomain.xml更加严格,我想知道有人可以给我贴一份他们知道有用的副本.在Adobe的网站上找到最近的样本有些麻烦.
我遇到了ajax请求的麻烦.我收到了错误
No 'Access-Control-Allow-Origin' header is present on the requested resource.
所以我尝试的是这个jQuery ajax请求:
var request = $.ajax({
type: 'GET',
url: url,
dataType: "json",
xhrFields: {
withCredentials: true
}
});
request.done(function(data){
console.log(data);
});
Run Code Online (Sandbox Code Playgroud)
但它仍然无法正常工作.我仍然得到错误.
我该怎么解决这个问题?
我正在建立一个cordova /离子应用程序,在我的手机(Android 6.0.1)工作正常,如在chrome(桌面),几天前我添加人行横道,以获得最佳功能,当我使用我的旧手机(Android 4.4. 1),但是,所有请求都会得到相同的错误.
GET https://firebasestorage.googleapis.com/v0/b/firebase-wodfit.appspot.com/o/i…e_user%2Fno-photo.jpg?alt=media&token=795a805a-af52-4d56-95e7-112a5ba6157d **net::ERR_INSECURE_RESPONSE**
Run Code Online (Sandbox Code Playgroud)
我尝试在config.xml中配置白名单插件,如:
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
Run Code Online (Sandbox Code Playgroud)
或内容安全:
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-eval' 'unsafe-inline' ; img-src 'self' data: *;">
Run Code Online (Sandbox Code Playgroud)
这是我的系统信息
>离子信息
Your system information:
ordova CLI: 6.5.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.9.1
Xcode version: Not installed
Run Code Online (Sandbox Code Playgroud)
一些cordova的插件:
cordova-plugin-crosswalk-webview 2.3.0 "Crosswalk WebView Engine"
cordova-plugin-whitelist 1.3.1 "Whitelist"
Run Code Online (Sandbox Code Playgroud)
> cordova平台版
Installed …Run Code Online (Sandbox Code Playgroud)