JSONP isteğiyle bir API'dan bazı veriler almaya çalışıyorum, ancak her seferinde 404 elde ediyorum. URL’imin yanlış olduğunu varsayabilirim, ancak Chrome’da manuel olarak URL’ye basabilir ve istenen yanıtı alabilirim. Benim $http.jsonp
her zaman hata geri aramada benim console.log
içinde bir 404 gösteren hataları ile istek. JSONP isteği, Angular uygulamasında 404 verir
$scope.fetchDefaultLabel = function() {
// This code will eventually set the label to the site name when the endpoint field blurs.
// Currently not working properly.
if ($scope.endpoint) {
var baseUrl = $scope.endpoint.split('/')[2];
var siteNameUrl = 'http://' + baseUrl + '/api/sitename.json?callback=JSON_CALLBACK';
console.log(siteNameUrl);
$http.jsonp(siteNameUrl)
.success(function(data, status, headers, config) {
$scope.label = data;
})
.error(function(data, status, headers, config) {
console.log('Data: ' + data);
console.log('Status: ' + status);
console.log('Headers: ' + headers);
console.log('Config: ' + config);
});
}
};
Ağ paneli ı beklenebilir yanıt gövdesinde istek için 200 tepkisini gösterir, ama bu herhangi bir nedenle Açısal alma değil.
bunu zaten gördünüz mü? http://stackoverflow.com/questions/19916362/angularjs-how-to-make-a-jsonp-request – klode
Klode Bunu gördüm. API, JSONP isteklerini desteklemiyor olabilir. Mümkün mü? – raddevon
Tam olarak aynı sorun var. – Miraage