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 .cli开发者_StackOverflow社区ck() 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);
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?
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!');
}
});
});
精彩评论