This code:
close: function (id) {
var defered = $q.defer();
$http.post('api/TopicSelection/Close', id).
success(function (data) {
defered.resolve(data);
}).
error(function (data, status, headers, config) {
defered.reject(data.message);
});
return defered.promise;
},
works perfectly in Chrome. However in IE 9, error callback is called straight away. data, status, headers are empty, and according to Fiddler/IE Network traffic, request is not sent.
What is wrong with it?
After some investigation it seems that IE 9 & AngularJS do not handle a case when I simply pass id as string in message body. When I changed it to:
$http.post('api/TopicSelection/Close', {id: id})
then the POST is sent with message body:
{"id":4611}
However, I don't want to have an object serialized. I want to have a simple request message body as string:
4611
Issue resolved. id has to be string:
$http.post('api/TopicSelection/Close', id.toString())
Note from Angular's reference:
data – {string|Object} – Data to be sent as the request message data.
The only annoying thing is version without toString was not coherent betweet browsers...
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