I am trying to load a js from a different domain in my Ember app. However, I get the following error;
XMLHttpRequest cannot load http://ift.tt/1Vt1no2. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
Below is the code I use to call the JS (AJAX)
var promise = new Ember.RSVP.Promise(function(resolve, reject) {
return $.ajax({
url: requestUrl,
type: 'POST',
dataType: 'JSON',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(postData),
async: isAsync
}).success(resolve).error(reject);
})
.catch(this.handleServerHTTPErrorCodes)
.then(this.handleCommonServerErrors);
return promise;
I also added the folowing config in environment.js
ENV.contentSecurityPolicy = {
'connect-src': "'self' http://ift.tt/1N6jJ7y"
}
How can I load an external JS in Ember ?
Aucun commentaire:
Enregistrer un commentaire