Jquery Ajax POST Snippet

This is how to do with jquery ajax with post method snippet;

    <input type="text" id="one" name="one">
    <input type="text" id="two" name="two">
    <div id="btnSubmit">Submit</div>
        var data = "one="+$("#one").val()+"&two="+$("#two").val();

And the other one is:

<form id="nu_form">
    <input type="text" name="a_name" />
    <input type="text" name="something" />
 <input type="submit" value="save" id="btn_save" />
        data: $("#nu_form").serialize(), 
        type: 'POST',  
        url: '/save_data', 
        success: function(response) { 
            alert(response); } 
    return false; 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s