Reputation: 479
Ajax call works, and deletes the file via unlink, however success is not called. I'm using this same exact ajax function elsewhere, only it is with the .click() event, not .live(). Could that be the issue?
$('.picture_delete').live("click", function() {
$.ajax({url: 'UrlWithArguments,
async: false, success: function () { alert("YAY!"); }
});//json });
This is the only relevant line of code being executed:
unlink($deleteMe);
Upvotes: 1
Views: 2717
Reputation: 72662
First you should check whether the onclick event is triggered:
$('.picture_delete').live('click', function() {
console.log('onclick event triggered'); // or you can do: alert('onclick event triggered');
$.ajax({
url: 'UrlWithArguments',
async: false,
success: function () {
alert('YAY!');
}
});
});
If the onclick event is triggered you should check whether the ajax call succeeds or fails:
$('.picture_delete').live('click', function() {
$.ajax({
url: 'UrlWithArguments',
async: false,
error: function(jqXHR, textStatus, errorThrown) {
console.log('AJAX call failed: '+textStatus+' '+errorThrown); // or you can do: alert('AJAX call failed: '+textStatus+' '+errorThrown');
},
success: function () {
alert('YAY!');
}
});
});
Upvotes: 1
Reputation: 10292
The success() function is normally called when a 200 response code is returned. Does your PHP code complete the request, or does it hang?
Have you tried using Firebug, etc. to see what the response looks like from your PHP file?
Upvotes: 2