This question has already been answered:
- Loss of context call 5 responses
If the problem is related to the control of the received item using jquery. Before sending an ajax request, you can get all the attributes of an element and influence it as you like, but in the body of the success function, you cannot access it. Maybe you need to somehow pass this to the function body? I give the code:
/* Events after clicking on save button */ $("table").on('click', '.glyphicon-ok', function () { var rowId = $(this).attr('id'); //Здесь работает alert($(this).attr('id')); /* Change the icon of button */ $(this).removeClass('glyphicon-ok').addClass('glyphicon-pencil'); $.ajax({ url: path, type: 'POST', cache: false, data: data, success: function (response) { //Здесь не работает alert($(this).attr('id')); /* Change the icon of button */ $(this).removeClass('glyphicon-ok').addClass('glyphicon-pencil'); } }); }); You need to get the element completely, since in case of success of the request Ajax, its attributes will change.