submitting form and variables together through jquery

前端 未结 2 1443
醉酒成梦
醉酒成梦 2021-01-17 01:30

I\'m using 2 types of submit.

There is $.post

$.post(\'servers_side.php\', { var1: var1, var2:var2},
function(result) 
{
some code...
});

2条回答
  •  花落未央
    2021-01-17 01:53

    Well, it's possible but code might look messy. As best practice you should add some hidden fields

    . . . . . .

    And use this JavaScript to set values to these hidden fields

    $("#var1").val("some data 1");
    $("#var2").val("some data 2");
    $("#var3").val("some data 3");
    

    And you can carry on with your existing $.post() code

提交回复
热议问题