How to post a form with many fields with jQuery?

后端 未结 7 2398
不知归路
不知归路 2020-12-15 06:46

Though $.ajax() can be used to do ajax things, I don\'t think its fit for posting values of a big form.

How would you post a big form (many fields) with

7条回答
  •  一生所求
    2020-12-15 07:24

    You can use jQuery.post( url, data, callback, type), as its simpler to jQuery.ajax( options ).

    By using serialize, you can send the whole form automatically.

    $.post("/post_handler/",
        $("form#my_form").serialize(),
        function(json){
            /*your success code*/
        }, "json");
    

    A more complete example:

    
    

    This would override the default post, and perform it with AJAX.

提交回复
热议问题