Reputation: 922
A jQuery .ajax() call of mine is not working in firefox but it is working in Chrome. Here is the ajax call:
$.ajax({
url: '/forms/remove_photo/' + temp,
complete: function() {
$('#photo').remove();
}
});
However, in firefox '/forms/remove_photo/' (which is a php function) is not being called, but the complete function is still executing. There are no parseErrors or syntax errors showing up in firebug. In chrome the function is being called and running successfully.
Has anyone encountered this problem before? Any help would be greatly appreciated. Thanks!
Upvotes: 0
Views: 1370
Reputation: 1734
I have had trouble with $.ajax
in firefox but it works like a charm in chrome, what happens it's that since chrome handles javascript and ajax faster, firefox seems to get left behind making you scratch your head, what you can do it's to use Deferreds That way you can handle ajax with more control, here is an example:
$.ajax({
url: '/forms/remove_photo/' + temp
}).done(function(){
$('#photo').remove();
});
I suggest you do some research to the Deferreds object as it will help you a lot
Upvotes: 0
Reputation: 4207
$.ajax({
cache: 'false', // just to clear your cache
url: '/forms/remove_photo/' + temp,
success: function() { // this may be more appropriate
$('#photo').remove();
}
});
Upvotes: 0
Reputation: 30473
Use success
instead of complete
:
$.ajax({
url: '/forms/remove_photo/' + temp,
success: function (data) {
$('#photo').remove();
}
});
Upvotes: 3