JSONP ajax 响应有回调位于另一个回调中,响应对象为空

JSONP ajax response has callback sitting inside another callback and response object is empty

我发现在发出此 ajax 请求时,如果我检查 chrome 的开发人员工具中的响应,它返回为:

callback(callback({...}))

内部回调指的是在 jsonpCallback 中指定的回调。如果我尝试在成功函数中读出响应,我会被告知响应未定义。

下面是我提出的 ajax 请求。

$.ajax({
    url: http://www.domain.com/cameraservice/1.0/getCameras,
    dataType: 'jsonp',
    jsonpCallback: 'callback',
    data: data,
    success: function(response){
        that.reset( that.parse(response.cameras.camera) );
        Vent.trigger('cameras.updated', that);
    }
});

在与同事交谈后,我们确定问题出在服务器端代码上。他对 return 数据进行了双重包装,导致有两种回调方法。