我有以下
angular.module('myApp').factory('dashboard', ['$http', function ($http) {
return {
name: function(str){
return str + ':' + 'works!';
},
getFlags : function(){
$http({ method: 'GET', url: 'http://dalsapent01:8080/DataService/TestDataService.svc/EventTypes', headers: { 'Content-Type': 'application/json; charset=utf-8', 'dataType': 'json' } })
.success(function (data, status, headers, config) {
alert(data);
}).
error(function (data, status, headers, config) {
alert(data);
});
}
}
}])
当我查看fiddler时,我看到JSON被返回,但状态总是0。有什么想法吗?
感谢
我认为您的服务器响应配置有问题
在这个plunker中尝试你的代码,一切都很好。