"Uncaught SyntaxError: Unexpected token :" with $http.jsonp
Have an application in angularjs. Server have in nodejs and expressjs. Have a problem with jsonp request (error - Uncaught SyntaxError: Unexpected token :).
var urlCallback = "http://api.asariweb.pl/apiListing/list?userId=[userId]&loginToken=[loginToken]&callback=JSON_CALLBACK";
$http.jsonp(urlCallback)
.success(function(data){
vm.realTimeData = data;
console.log('vm.realTimeData', vm.realTimeData);
});
In chrome, in "network", i have a good response, only without jsonp wrapper function -
{success: true, totalCount: 1368, data: [{id: 5510013, listingId: "3685/2517/OMS", label: null,…},…]}
data: [{id: 5510013, listingId: "3685/2517/OMS", label: null,…},…]
success: true
totalCount: 1368
Other url, for example 'https://api.dailymotion.com/videos?fields=id,audience,onair&ids=xzttq2_c,xrw2w0&callback=JSON_CALLBACK' is working fine.
为了使$http.jsonp
正常工作,您需要将请求返回的数据包装在适当的回调函数中:
// response
JSON_CALLBACK({"prop":"value", "prop2":"value2"});
链接地址: http://www.djcxy.com/p/46022.html
上一篇: API调用:未捕获SyntaxError:意外的标记:
下一篇: “Uncaught SyntaxError:Unexpected token:”with $ http.jsonp