Link to home
Start Free TrialLog in
Avatar of error77
error77

asked on

Submit a form using JQuery Ajax

Hi all,

I have a form and I'm submitting it the traditional way.

I need to do this without the page going away or refreshed. Ajax.

Can anyone give me simple instructions on how to do this please?

I prefer the JQuery way if possible.

Thanks

Avatar of Deja Anbu
Deja Anbu
Flag of Oman image

here is a simple one

http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/

but what is the server side language u use?
Avatar of error77
error77

ASKER

I use PHP.

I've seen that tutorial before but I asked here because I wanted it broken down to the bones.


ASKER CERTIFIED SOLUTION
Avatar of OmniUnlimited
OmniUnlimited
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Actually, your response could contain anything that you want:

$response = json_encode( array(
     'success' => true,
    'status' => "Let's party"
));
And then access them through the success function:

      $.ajax({
            cache: false,
            url: 'http://yoursite.com/process.php',
            type: "POST",
            data: ({
                                            // List your post variables and their values
                                             fullname : fullname,
                email : email  // etc.
                                        }),
            dataType: "json",
            success: function(data){
                  if(data.success)
                     alert(data.status); // Displays "Let's Party"
                                              // what you want done after successful transmission
                                        }
         });