Excluding certain inputs on serialize

前端 未结 6 1111
长发绾君心
长发绾君心 2020-12-29 20:05

I am trying to exclude an input by name (it is a hidden input holding my nonce)

The following question is almost what I am looking for:

How do I use jQuery&#

6条回答
  •  囚心锁ツ
    2020-12-29 20:28

    First, you need to invoke the .find() method like:

    var serializedReturn = $(this).find('input[name!=security]').serialize(); 
    

    Otherwise the complete string would go into the css query engine (Sizzle).

    Secondly:

    I have another form with the id of ofform-reset and if i use:

    You need to change this. It's invalid markup to have multiple ID's. If I understood you wrong here, the first solution might also help you here, invoking the .find() method aswell:

    var serializedReturn = $('#ofform').find('input[name!=security]').serialize(); 
    

提交回复
热议问题