When using the GET
request from a $resource
, the response on success is an empty array in Microsoft Internet Explorer 9 only.
Scenarios of Success:
GET
request returns an array of data in both development and local environments.Scenario of failure:
Debugging steps:
var 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])
...
Any help in debugging this would be greatly appreciated! Thanks in advance.
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';
}]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With