--
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 angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
Hi Anubha,
AngularJS is a bit more strict as plain js for security reasons. In some cases that’s a bit of a PITA as you noticed!
However, as your code is using angular, but still IS js, you can use plain JS to do the fetching.
create a service that does the request, and wrap it in a promise, something like this:
angular.module('goFetch',[])
.service('goSoap',[
'$q',
function ($q) {
this.get = function (parameters) {
var defer = $q.defer();
var xmlhttp = {} // do your normal xmlhttprequest setup here!
xmlhttp.onreadystatechange = function(e){
try{
if(xmlhttp.readyState == 4){
if(xmlhttp.status == 200){
defer.resolve('received full API response')
}else{
defer.resolve('oops')
}
}
}catch(e){
defer.reject('HOLY...');
}
};
return defer.promise;
}
}]);
After you injected this service into your controller, you can use it like this goSoap.get(paraemters).then(...).catch(...)
Does this help you?
Regards
Sander