【发布时间】:2015-03-11 20:33:10
【问题描述】:
我有一个 SPA,我正在尝试使用角度 $http.jsonp 从远程 .NET WebAPI 获取 JSON 数据
var widgetApp = angular.module('widgetApp', ['ngRoute']).config(function($interpolateProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
});
widgetApp.controller('topStreaksCtrl', function ($scope, $http) {
$http.jsonp('http://REMOTESERVER.azurewebsites.net/api/Serie/getdata?callback=JSON_CALLBACK')
.success(function(response){
$scope.data = response;
}).
error(function(data, status, headers, config){
console.log(data);
console.log(status);
console.log(headers);
console.log(config);
})
});
angular.bootstrap(document, ['widgetApp']);
我可以在 Chrome 网络上看到响应数据,但 jsonp 函数总是返回错误。状态 404 ? WebAPI 上需要任何配置吗?
【问题讨论】:
-
你能做到吗?
标签: .net angularjs azure asp.net-web-api jsonp