ajax - Odd bug in my jQuery seems to prevent an event from firing -


i have ajax request follows:

jquery.ajax({     type: 'get',     url: '/logical_interface/delete',     context: this, // had add line in success function work, never used before nor understand why works     data: 'id=' + id,     beforesend: function() {         // jquery(this).parent().html('processing...');         // if line uncommented dom updated correctly         // snippet in success function won't fire delete         // still executed on server side         // page stuck 'processing' text     },     success: function(data) {         jquery(this).closest('tr').stop().animate({ backgroundcolor: '#ffc6be' }, 'fast').hide('slow');     }  }); 

update

server side code following rails method:

def delete   @logical_interface = logicalinterface.find(params[:id])   @logical_interface.destroy   render :text => '1' // in console.log end 

as mentioned in comments, reason success may not work because deleted $(this) node.

what doing in beforesend function going 1 level , replacing all html "processing...". in turn deleted reference point jquery(this) dom before success case reached. if jquery(this) removed nothing happens (obvious).

instead of overwriting entire html processing, may suggest have single element hidden until trigger ajax , show beforesend , hide complete function.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -