In relation to can't debug hanging $.post in firefox extension
can anyone tell me why my extension https://builder.addons.mozilla.org/addon/1022928/latest/ is with this ajax call:
var url = 'http://e-ønsker.dk/wishlist/ajax/add/';
$(this).hide();
//show icon loading
$("#icon").show();
$.ajax({
type: "POST",
url: url,
data: {title:$("#txtTitle").val(), url:encodeURIComponent(taburl)},
success: function(data, textStatus) {
if(data.code > 0)
{
$("#icon").removeClass().addClass('accept');
}
else
{
$("#icon").removeClass().addClass('error');
if(data.code == '-1')
alert('kunne ikke finde din ønskeseddel på e-ønsker.dk - besøg e-ønsker.dk, og prøv derefter igen');
}
},
error: function(data, textStatus) {
alert(textStatus);
$("#icon").removeClass().addClass('error');
}
});
is returning the error NS_ERROR_DOM_BAD_URI. HttpFox says it’s a 500 error which would indicate an internal error, but this exact call works from both chrome and safari in their extensions, so I’m suspecting the error to be related to firefox specifically.
UPDATE
So I added dataType: "jsonp" and that did some of the magic, now I get a 200 response, but I still get a parsererror.
Weirdest thing is that after I modify my server to accomodate JSONP jquery chooses the error method, and the xhr.statusText that I show here alert(xhr.statusText); gives me an alert with the statustext “success” why won’t jquery choose the success method when it actually works??
You cannot get data from a different domain from the one you are currently on using AJAX -> http://en.wikipedia.org/wiki/Same_origin_policy
If you are using the same domain then use relative paths … I suspect that Firefox is encoding the
e-ønsker.dkpart of the url – making it look like a different domain.