On 10/9/07, marlyred <[EMAIL PROTECTED]> wrote:
>
> I recently implemented the following on another site i was working on..
> http://www.roscripts.com/AJAX_contact_form-144.html
>
> This example however uses the mootools loibrary, but as I am using jquery
> for some other stuff on my current site I was wondering if it was possible
> to do the same kind of thing using jquery, and then make the necessary
> alterations to turn it into a 'recommend us/tell-a-friend form.

Hi,

You should be able to get that roscripts solution working with jQuery
by just rewriting the mootools component as jQuery. Here is my simple
attempt:

 $(document).ready(function(){
        $('#myForm').bind('submit',function(){
                var log = $('#log_res').empty().addClass('ajax-loading');
                $.ajax({
                        type: "GET",
                        url: log.attr('action'),
                        data: $('input[type=text],textarea',this).serialize(),
                        success: function(msg){
                                log.removeClass('ajax-loading').append(msg);
                        }
                });
                return false;
        });
});

I'm no ajax expert so I was unsure about how to get the form data to
send, so I just stuck with sending data from text inputs and textareas
only, which should do to get their existing demo page working. For a
more flexible script maybe you need to include the Forms plugin so
that all the form data is sent.

Anyway, this is by no means a complete solution, but if you dropped it
into their demo in place of the mootools script and it works, then you
are one step closer I suppose. Be aware that their PHP script could
probably be more secure than it currently is as i doesn't seem like
any of the data is being sanitised.

Joel Birch.

Reply via email to