#### 1. HTML 表單 --- ```html <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> ``` #### 2. Javascript 函數(shù) --- ```javascript /** * 提交表單 */ 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; } ```