scope - Using $(this) within .get is undefined in jQuery -
I'm using a shorthand AJAX call, $ Get But when I try and reference the variable with $ (this) , it tells me that it is undefined.
The code block:
$ ( '. ReplaceWithObject' click ', function (event) {var cid = $ (this) Kfnd (' input '). Val (); $ .get (' GetVideoComment.ashx? Cid = '+ cid, function data) {$ (this) .html (data);});}); This is just cid just fine, as $ (this) is available before $$ Code>. Under .get $ (this) is undefined $ (this) to be set before get Does not work?
getVideoComment.ashx? Cid = 628 works, it gives a flash object The problem is that $ (this) is undefined within get .
Any ideas about what I want to do here? Or am I doing wrong?
You need to cache your initial selection, so it is present when your callback fire.
$ ('.withWebObject'). Live ( 'click', function (event) {var $ this = $ (this); var cid = $ this.find ( 'input') .val (); $ .get ( 'GetVideoComment.ashx? Cid =' + Cid, function (data) {$ this.html (data);});});
Comments
Post a Comment