在使用从 $资源
的 GET
的要求,对成功的响应是Microsoft Internet空数组资源管理器9只。
When using the GET
request from a $resource
, the response on success is an empty array in Microsoft Internet Explorer 9 only.
成功的情景:
使用FF或Chrome浏览器时, GET
请求返回的开发和当地环境数据的数组。
在IE9访问本地服务器,获取请求返回数据的数组。
Using FF or Chrome, the GET
request returns an array of data in both development and local environments.
IE9 accessing a local server, the "GET" request returns an array of data.
失败的情景:
IE9访问的发展服务器,则返回一个空数组。 IE9 accessing the development server, an empty array is returned.调试步骤:
在IE9访问的发展服务器: 键入的URL的REST API将成功返回数据的数组。 ✓ 通过调试步进验证发送到服务器的数据是数字和正确的值的。 ✓ 发布数据到另一个$资源工作正常 - 数据持久保存在数据库中,是正确的。 ✓ 通过调试器步进显示了成功的方法空数组。 ✗ In IE9 accessing the development server: typing in the URL to the REST API will successfully return an array of data. ✓ stepping through the debugger verifies that the data sent to the server are numbers and of the correct value. ✓ POSTing data to another $resource works fine - data is persisted in the database and is correct. ✓ stepping through the debugger shows an empty array in the success method. ✗ 在REST API的工作,因为直接要求退货的数据 角应该是工作,因为结果在FF和铬返回 是否有任何其他提示来调试这个问题? 在什么能这样做的原因是什么? 是否与Ajax请求任何IE9的具体问题? AngularJS 1.2.0 $资源响应为空 - 在我的情况,我得到的回应,它只是一个空数组 AngularJS厂HTTP返回空 - 目前的问题是,IE9仅 AngularJS 1.2.0 $resource response is empty - in my case, I get a response, it's just an empty array AngularJS factory http returns empty - current issue is IE9 onlyvar AnswerSetBySubjectByForm = function($resource) {
return $resource('/rest/answerset/subject/:idSubject/form/:idForm',
{ idSubject : '@idSubject', idForm : '@idForm'},
{'get' : {method:'GET', isArray:true}}
);
};
var AnswerSetController = function($scope, AnswerSetBySubjectByForm) {
...
$scope.$on('loadAnswerSets', function(e, idSubject, idForm) {
if (angular.isNumber(idSubject) && angular.isNumber(idForm)) {
AnswerSetBySubjectByForm.get({
idSubject : idSubject,
idForm : idForm
}, function(answerSets) {
/* answerSets is an empty array in IE9 only */
$scope.answerSets = angular.copy(answerSets);
});
}
});
...
...
app
.factory('AnswerSetBySubjectByForm',
['$resource', AnswerSetBySubjectByForm])
.controller('AnswerSetController',
['$scope', 'AnswerSetBySubjectByForm', AnswerSetController])
...
任何帮助调试这将是极大的AP preciated!先谢谢了。
Any help in debugging this would be greatly appreciated! Thanks in advance.
在你的角度code到被缓存prevent GET请求做到这一点
Do this in your angular code to prevent GET requests being cached
app.config(['$httpProvider', function ($httpProvider) {
//Disable caching and make sure the call is made for each GET request.
//Especially for IE, disable ajax get request caching
$httpProvider.defaults.headers.get = $httpProvider.defaults.headers.get || {};
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
}]);