我正在使用Angular JSON Http调用。同样当我发布这样的帖子请求时:
app.service('AjaxService', [ '$http','$q','$sce', function($http,$q,$sce) {
return {
getSearchResultsJSONP : function() {
var url="http://stage-sp1004e4db.guided.lon5.atomz.com/?searchType=globalsearch&q=this&sp_staged=1&callback=JSON_CALLBACK";
$sce.trustAsResourceUrl(url);
$http.jsonp(url)
.success(function(data) {
console.log("Data for default SNP call" ,data);
}).
error(function (data) {
console.log("request Failed ! ");
});
},
getSearchResult : function(searchText,url){
var defer = $q.defer();
$http({
url: url,
method: "GET",
params: {searchresInput: searchText}
}).then(function(data, status, header, config){
defer.resolve(data);
}).then(function(data, status, header, config){
defer.reject(data);
});
return defer.promise;
}
};
}]);
我可以看到网络中的数据,响应状态为200 OK。
但是我在完整的代码运行期间收到错误:
Uncaught TypeError: Cannot read property 'parentElement' of undefined
at checklistFunc (masterlowerlibs.67785a6….js:42972)
checklistFunc @ masterlowerlibs.67785a6….js:42972
有人可以帮助我,如何解决这个问题或者出了什么问题?
我的回答如下:
angular.callbacks._0({metadata: {,…}, pagination: {totalpages: "1", firstpage: "", pagelinks: {pagelink: [,…]}},…})
facets
:
[{}, {}, {}, {}, {}, {}, {}, {}]
metadata
:
{,…}
pagination
:
{totalpages: "1", firstpage: "", pagelinks: {pagelink: [,…]}}
results
:
[,…]
sort
:
[{selected: true, name: "default", value: "relevance"}, {name: "Latest", value: "tkh_pageDate"}]
答案 0 :(得分:4)
如果您单击错误代码行,我假设您获得了缩小/混淆代码,因此我建议您使用AngularJS Batarang插件安装和调试Chrome浏览器。
我希望这有助于理解错误发生的原因。