OK. I haven't tried this yet, but how is this any different? Even
though you're moving the ajax call inside of another function, aren't
you abstracting the same logic out by calling the anonymous function
inside of success? Maybe I'm not understanding what "trigger" and
"trigger condition" are supposed to represent, but I assumed that was
related to my isNaN(r) logic.

Thanks,
-Wayne

On Oct 8, 12:36 pm, "Josh Nathanson" <[EMAIL PROTECTED]> wrote:
> "this" referenced in the success callback will refer to the jQuery object
> when you do an ajax call.
>
> You might want to put the ajax call within another function that can also
> receive information about the triggering element:
>
> doAjax: function( trigger ) {
>         jQuery.ajax({
>             // etc.
>             success: function() {
>                 if ( trigger condition ) {
>                     // do stuff
>                 }
>             }
>     });
>
> }
>
> $("triggeringelement").click(function() {
>         doAjax( this );
>
> });
>
> -- Josh
>
> ----- Original Message -----
> From: "Wayne" <[EMAIL PROTECTED]>
> To: "jQuery (English)" <jquery-en@googlegroups.com>
> Sent: Wednesday, October 08, 2008 7:49 AM
> Subject: [jQuery] AJAX Success Callback referring to $(this)
>
> > I've been looking for this quite a bit, today, and haven't quite found
> > what I'm looking for, so maybe someone can point me in the right
> > direction.
>
> > I'm performing an AJAX request, and I pass an anonymous function as
> > the success callback, upon which I will want to do some DOM
> > modification to the element that triggered the AJAX event. Ordinarily,
> > $(this) would work fine for doing this, but it seems that $(this)
> > points instead to something besides a DOM element.
>
> > First, what does $(this) point to when you're inside the AJAX Success
> > callback.
>
> > Second, what is considered the best practice for accessing the
> > triggering element after a successful AJAX query?
>
> > Any help is appreciated,
> > Wayne
>
>

Reply via email to