I am giving a call with click, and this will go to server call.
$(this).click(function(){
alert($(this).html()); //this is giving value
var urlLink = someURL;
var data = "id=" + "123";
$.ajax({
url : urlLink,
data : data,
cache: false,
success : function(resp) {
alert($(this).html()); //this is giving null
}
});
});
Once after success, if i alert the same giving null. could any once please give an idea, what’s going wrong.
From the jQuery documentation:
Either set the
contextoption of the ajax object, or save the object in a variable outside the scope of the callback function.