Bring $(this) with callback-function in $.post
Wanted to use the $(this)-variable to be able to specify some values when doing a $.post, the problem is, when specifying a callback-function, the $(this)-variable doesnt tag along. Inside the function it is undefinied but outside it is :/
Any suggestions how to fix that in a proper way? I had to do my script inside the function directly instead and then return a fake-value, but it doesnt seem like a good way to work around it since you doesnt really know if the callback-function really is a success or not:
instead of
-
function () {
$(this).find("...").each(function() {
$.post(...);
});
}
I had to write:
-
$(this).find("...").each(function() {
$.post(...);
}).is("..."); //The "is" is used only to return a boolean value to prevent s.success error
Thanks!!
Carl-Johan