$(this) refers only to the scope of the function. outside the function, however, it loses this link:
$('.classSelect').one("click", function() { $(this); // refers to $('.classSelect') $.ajax({ // content $(this); // does not refer to $('.classSelect') }); });
the best way to handle this might be:
$('.classSelect').one("click", function() { var e = $(this); $.ajax({ ... success : function(request) { e.html(request); } });
By the way, are you familiar with the
load() method? I find it easier for basic ajax (since it acts on a wrapped set, instead of being a standalone function like
$.ajax() , for example). Here I would rewrite this with
load() :
$('.classSelect').one('click', function() { var options = { type : 'post', dataType : 'text', data : { '_service' : myService, '_program' : myProgram , 'param' : myParams } }
source share