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

JavaScriptAJAX

Avatar of undefined
Last Comment
OmniUnlimited

8/22/2022 - Mon
dejaanbu

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?
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
OmniUnlimited

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
OmniUnlimited

Actually, your response could contain anything that you want:

$response = json_encode( array(
     'success' => true,
    'status' => "Let's party"
));
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
OmniUnlimited

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
                                        }
         });