我正在编写一个简单的phonegap + framework7应用程序,该应用程序需要从localhost网址获取数据。
我所做的一切都不适合我
var app = new Framework7({
// App root element
root: '#app',
name: 'My App',
id: 'com.domain',
panel: {
swipe: 'left',
},
routes: [
{
path: '/about/',
url: 'about.html',
},
]
});
$$(document).on('deviceready', function() {
var REMOTE_SERVER_URL = http://localhost/projects/ajax/get.php;
app.request.json(REMOTE_SERVER_URL + "?callback=?", function (res){console.log(res)})
});
最后出现以下错误
源“ http://localhost/projects/ajax/get.php?callback=f7jsonp_1548277709852”的加载失败
php脚本头文件
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header('content-type: application/json; charset=utf-8');
我尝试了本地主机和本地IP,都给出了相同的错误,如果我将链接复制到浏览器中就可以了
此处是政策的元数据
<meta http-equiv="Content-Security-Policy" content="default-src *
'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline'
'unsafe-eval'; connect-src * 'unsafe-inline'; img-src *
data: blob: 'unsafe-inline'; frame-src *; style-src *
'unsafe-inline'">
不确定为什么