I've dealing with this issue for the past month, I've read almost all the posts here at stackoverflow, but no way... my best approach was:
$.ajax({
url: "https://connect1.facebook.net/" + ('BR' == $('#country').val() ? 'pt_BR' : 'es_LA') + "/sdk.js",
dataType: "script",
cache: false,
xhr: function () {
var xhr = new window.XMLHttpRequest();
//Not working...
xhr.onerror = function(e) {
alert("Error Status: " + e.target.status);
};
//Frustration ends here...
return xhr;
}
})
.done(function(data) {
console.log("Ajax success");
init();
callback();
});
The "connect1" makes the request to fail, but I cant get a way to catch the error because of the famous issue with crossdomain requests. My best bet was to implement my own xhr object, but the onerror event is not being triggered.
I wrote this post because any new or fresh idea will help me a lot.
UPDATE: This is the url that you can use to replicate the request, that is intended to fail: https://connect1.facebook.net/es_LA/sdk.js?_=1445285186108
Thanks so much in advance.
Guillermo