【问题标题】:Getting syxtax error using JSONP call back - angularJs使用 JSONP 回调获取语法错误 - angularJs
【发布时间】:2016-08-02 05:54:42
【问题描述】:

服务

some.factory('homeService', ['$http', function($http){

        return {

            getEvents : function(url) {

                return $http.jsonp(url);
            }
        }

    }]);

控制器

homeService.getEvents("http://server.some.io/s/first?callback=JSON_CALLBACK")
    .then(
        function(response){
            $scope.events = response.data.events;
        });

错误:未捕获的 SyntaxError:意外令牌

即:json对象:{"meta": {"has_next": false, "status": 200, "place":.....

错误指向“元”之后

有什么线索吗?

【问题讨论】:

  • 当然。您的“JSON”响应不是“JSONP”响应。你不能用javascript解决这个问题。 server.some.io 似乎不支持 JSONP。
  • 是的。它正在返回常规 json

标签: angularjs json jsonp


【解决方案1】:

服务器未返回 JSONP 格式。固定在服务器上。

【讨论】:

    猜你喜欢
    • 2013-01-09
    • 2014-12-03
    • 2013-10-22
    • 2012-02-16
    • 1970-01-01
    • 1970-01-01
    • 2012-05-30
    • 1970-01-01
    • 2016-04-21
    相关资源
    最近更新 更多