hitch could do this. http://higginsforpresident.net/js/jq.hitch.js http://higginsforpresident.net/js/jq.hitch.min.js ... 'success': jQuery.hitch(this, function(msg){ alert($(this).attr('id')); }), ...
Regards On Fri, May 1, 2009 at 12:48 PM, phpdevmd <phpde...@gmail.com> wrote: > > Hello, I have the following jquery ajax request: > > <html> > <head> > <script type="text/javascript" src="jquery-1.3.2.min.js"></script> > </head> > <body> > <a href="#" id="yt1">Approve</a> > <script type="text/javascript"> > /*<![CDATA[*/ > jQuery(document).ready(function() { > jQuery('#yt1').click(function(){ > $(this).replaceWith("<i>Approving...</i>"); > jQuery.ajax({ > 'type':'POST', > 'data':'id=205', > 'dataType':'text', > 'success':function(msg){ > alert($(this).attr("id")); > }, > 'url':'/approve/article', > 'cache':false > }); > return false; > }); > }); > /*]]>*/ > </script> > </body> > </html> > > First replaceWith working fine, link changes to 'Approving', but alert > saying 'undefined' instead of 'yt1'... > Any ideas acessing this link in a script where I don't know exactly > what id does this link have? > I know that alert($("#yt1").attr("id")); would work, but 'yt1' is auto- > generated by my framework, so I need to access it without $("#_id_") > but using 'this' or any other appropriate method. > > Thanks in advance. > Roman >