Ajax 提交表单数据
<form id= "userForm" >
<input type="text" name="username" value="123">
<input type="text" name= "password" value="abc">
</form>
1.serialize()
$('#userForm').serialize(); // "username="123&password="abc"
2.serializeArray() --返回对象数组
$("#userForm").serializeArray();
//[{name: "username",value: "123"},{name:'passward', value: "abc"}]
3.serializeObject() --返回对象
let array = $("#userForm").serializeArray();
for( let i = 0; i < array.length; i++ ){
file.append(array[i].name, array[i].value); // 变为json对象格式
}
//{username: "123", passward: "abc"}
$('#userForm").serializeObject();
//{username: "123", passward: "abc"}