Kamis, 05 Juni 2014

Snippet for JQuery Ajax Post Method

This is how to do jquery ajax with post method;

Method 01;

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

Method 02;

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

Tidak ada komentar:

Posting Komentar