The following Javascript code works fine and returns data:
var request = { id : 0, method : "someMethod", params : [] };
var http = new XMLHttpRequest();
http.open('POST', url, false);
http.withCredentials = true;
http.setRequestHeader('Content-Type', 'text/plain');
http.send(JSON.stringify(request));
But similar representation of that code in Angular fails:
module.factory("service", function ($http, $q) {
return {
getData : function(){
var request = { id : 0, method : "someMethod", params : []};
var deferred = $q.defer();
var response = $http({
method: "post",
crossDomain: true,
withCredentials: true,
contentType: "text/plain",
request: JSON.stringify(request),
url: ".......",
});
response.success(function (data) {
deferred.resolve(data);
});
response.error(function (data) {
alert('Error');
});
// Return the promise to the controller
return deferred.promise;
}
}
});
The error is this:
POST http://localhost:......... net::ERR_INVALID_HANDLE
Any idea?
Thanks
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.