<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<form action="" method="post" onsubmit="return save(this)">
手机号 <input type="text" name="mobile" autocomplete="off">
登录密码 <input type="text" name="password" autocomplete="off">
<button>提交</button>
</form>
/**
* 提交表单
*/
function save(obj)
{
var formData = {};
var array = $(obj).serializeArray();
$.each(array, function() {
formData[this.name] = this.value;
});
console.log(formData)
$.ajax({
url: '',
type: 'post',
async: false,
data: formData,
success: res => {
console.log(res)
}
})
return false;
}