How can I access the value of $(this) after success: function() when using jquery? No matter what I\'ve tried, it appears I cant do it.
$(\'.add\').click(functio
This is a problem with scope. You need to assign this
to a variable within the scope of where it is accessible. Then use that variable in child functions.
Note I've used _that
This should work, please comment if it doesn't.
$('.add').click(function() {
var _that = this;
$.ajax({
type:"GET",
url:"/",
data:data,
dataType: 'json',
beforeSend:function(html){
//Nothing here right now
},
success: function(){
$(_that).parent("div").after("I'm the new one.");
},
});
});