Modify POST vars before post, using jQuery

前端 未结 8 716
醉话见心
醉话见心 2020-12-29 18:34

I have a form, and a submit handler in jQuery.

When the user submits the form, I want to modify (add) some parameters to the POST request, before it is despatched fr

8条回答
  •  天命终不由人
    2020-12-29 19:02

    Attach a submit() handler to the form.

    $('form#myForm').submit(myPostHandlingFunction);
    

    Then submit/ do the post from your function. The easiest thing would be to just populate a couple of hidden inputs in the form and then return true to allow the submit to happen if everything looks right.

提交回复
热议问题