I have the following bit of code, which works fine in every modern browser, but fails in Internet Explorer 9 and below.
authService.login = function(credentials) {
return $http.post('https://example.com/login', credentials).then(function(res) {
return res;
}, function(err) {
return err;
});
};
credentials
is an object that looks like this:
{
username: 'john@example.com',
password: 'smith'
}
The problem is that the POST never actually happens, instead it jumps straight to return err;
and no error is even set. It says Impossible d'effectuer l'opération à cause de l'erreur suivante c00c023e.
. The key being c00c023e, which is supposedly an encoding problem, but I don't see how that would completely prevent the call from happening.
The 'fix' is to use $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
which does allow IE to POST, but my backend expects JSON so that doesn't help.
I'm using AngularJS 1.2.22.
Any ideas?