У меня есть запрос Ajax следующим образом:Одд ошибка в моей JQuery, кажется, чтобы предотвратить событие от стрельбы
jQuery.ajax({
type: 'GET',
url: '/logical_interface/delete',
context: this, // had to add this to get the line in the success function to work, never used it before nor do I understand why it works
data: 'id=' + id,
beforeSend: function() {
// jQuery(this).parent().html('processing...');
// if this line is uncommented then the DOM will be updated correctly
// but the snippet in the success function won't fire but the delete
// is still executed on the server side
// the page is then stuck with the 'processing' text
},
success: function(data) {
jQuery(this).closest('tr').stop().animate({ backgroundColor: '#ffc6be' }, 'fast').hide('slow');
}
});
Update
стороне сервера код просто следующий метод Rails:
def delete
@logical_interface = LogicalInterface.find(params[:id])
@logical_interface.destroy
render :text => '1' // which is what I get in console.log
end
... И? Что происходит? –
Является ли 'jQuery (this) .closest ('tr')', что вы думаете? Что произойдет, если вы добавите 'console.log (данные),' после этой строки - что-нибудь в журнале? –
HTML-код элемента ('td') обновляется с помощью' processing', но анимация для удаления всей строки в обратном вызове 'success' не срабатывает. – martincarlin87