且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用JQuery Ajax提交特定的表单

更新时间:2022-12-19 17:39:07

试试这个:

Try this:

$(document).on('click','button.btn',function(e) { 
    //you will trigger this function when you click a button
    //this will select the parent, i.e., the form
    var form = $(this).parent();

    var data = form.serialize();
    $.post('game/write.php', data, function(response) {
        console.log(response);
        $('#power').replaceWith(response);
    });
    return false;
});