Mike... Thanks for your response. I'll give that first one a try. The only reason I can't use the second method is because I'll have multiple forms on any one page. So I need to insert before this specific form and not just .commentForm in general.
-----Original Message----- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mike Alsup Sent: Friday, August 24, 2007 9:28 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: $(this) after using ajaxForm from the Form plugin? Andy, Your callback is passed three args: 1. data 2. status 3. form wrapped in jQuery object So this should work: $('.commentForm form').ajaxForm(function(data, status, $form) { $form.before(data.split('!!!')[1]); }); Of course there's no reason this wouldn't work too: $('.commentForm form').ajaxForm(function(data, status, $form) { $('.commentForm form').before(data.split('!!!')[1]); }); Mike On 8/24/07, Andy Matthews <[EMAIL PROTECTED]> wrote: > > Anyone have any comments on this? > > -----Original Message----- > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] > On Behalf Of Andy Matthews > Sent: Thursday, August 23, 2007 10:31 PM > To: jQuery (English) > Subject: [jQuery] $(this) after using ajaxForm from the Form plugin? > > > I'm planning on using the Form plugin for an AJAX submission, where > when the callback function is fired, it adds the returned data just > before my the content form. Fairly standard right? Here's my HTML > code: > > <div class="commentShell"> > <div class="openComments">Comments <i>(3)</i></div> > <div class="comments"> > <div class="singleComment"> > <p>I know...he's so poetic isn't he? Noelle > HAS been really cute lately too.</p> > <i><a href="http://www.andyandjaime.com" > target="_blank">Jaime Matthews</a></i> <i>- August 23, 2007 07:25 pm</i> > </div> > > // insert new comment right here > > <div class="commentForm"> > <form name="addcomment" action="comment.cfm" > method="GET"> > Your Name: <input type="text" name="visitor" > class="commentInput"><br> > <input type="submit" value="Speak!" > class="speak" style="font- > size: .9em;"> > </form> > </div> > > </div> > </div> > > > And here's the snippet of jQuery code > $('.commentForm form').ajaxForm(function(data) { > alert(data.split('!!!')[1]); > // $('.commentForm').before(data.split('!!!')[1]); > $(this).fadeOut(); > }); > > This sounds weird but, I don't know what $(this) is in the context of > the jQuery function. I "thought" that it would be the form itself but > I've tried various things and I can't get ANYTHING to respond. > Everything I try comes back as undefined. So the problem is that I > can't use the .before() method because I don't know where I am in the > document when the user submits the form. > > Can someone shed some light please? Thanks. > > >