javascript - About form submission data
PHPz
PHPz 2017-05-19 10:20:04
0
6
881

There are multiple input fields in the form for data display. Now click the button to submit some data, but some fields in the form do not need to be submitted. How to deal with it. Usually all submissions are submitted using ajax's serial number, such as $('form').serialize(). Now I only need to submit some fields and I don’t know how to write them. Please give me some advice!

PHPz
PHPz

学习是最好的投资!

reply all(6)
我想大声告诉你

Jquery serialization is for elements with name attributes. If you want to remove some fields without submitting them, just remove the name attributes. This data will not be submitted when submitting.

大家讲道理

Use jQuery 获取部分 inputvalue

$("input").val()

Then send the data

某草草

Split it into two forms so that you can submit them separately

洪涛

Take out the value to be submitted and submit it as a json array

$.post{url,{a:'a',b:'b',c:'c'},function(){}}
我想大声告诉你

Write a few more froms to submit as needed, or take the required values ​​and submit them, or take all the values ​​and then filter them,
or set the input attributes that do not need to be submitted to disabled.

某草草
var formData = $.param({
                actionID : 'publishExam',
                classInfo : getCheckedVal("classInfoName").toString(),
                bookletUnitInfo : getRadioVal("unitradio")
            }) + "&" + $("#examForm").serialize();

For reference!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template