【发布时间】:2016-08-03 14:40:19
【问题描述】:
我的客户端应用程序是一个 angularJS 应用程序。服务器由 Laravel 5 构建。
在客户端,我进行 jsonp CORS 请求:
$http.jsonp("http://server.com/api?callback=JSON_CALLBACK")
在laravel服务端,返回一个json数据:
return Response()->json($query);
但是,当我尝试时
$http.jsonp("http://server.com/api?callback=JSON_CALLBACK")
.then(function(response){
alert('success');
});
或
$http.jsonp("http://server.com/api?callback=JSON_CALLBACK")
.success(function(response){
alert('success');
});
两种状态都是200 OK。但不会出现任何警报。我试试
$http.jsonp("http://server.com/api?callback=JSON_CALLBACK")
.then(function(response){
alert('success');
},function(error){
alert('fail');
});
结果是200 OK 的状态,但警报是“失败”!我怎么解决这个问题?谢谢!
【问题讨论】:
标签: javascript php angularjs laravel jsonp