Here is my service. It will request data from a different domain:
reports.factory("service", function ($http, $q) {
return {
getData : function(dateFrom, dateTo){
var deferred = $q.defer();
var response = $http({
method: "post",
crossDomain: true,
dataType:"xml",
contentType: "application/xml",
headers: {'X-PINGOTHER' : 'pingpong'},
url: "http://localhost:7070/......,
});
response.success(function (data) {
deferred.resolve(data);
});
response.error(function (data) {
alert('Error');
});
// Return the promise to the controller
return deferred.promise;
}
}
});
When I run it I get:
OPTIONS http://localhost:7070/........ 401 (Unauthorized) angular.js:7997
XMLHttpRequest cannot load http://localhost:7070/.......... Invalid HTTP
status code 401
My web.config on 7070 has the following part:
<customHeaders>
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With,
Content-Type, Accept, X-PINGOTHER" />
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" />
</customHeaders>
The funny part that if I run Charles it works fine, without all these
exotic headers in config file and headers line in service definition.
Please share 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.