這是我們的代碼 <div class="col-2"> <div class="input-group"> <label class="label">Name</label> <input id="name" class="input--style-4" type="text"> </div>和JSvar btn = document.getElementById("register");var email = document.getElementById("email");var pw = document.getElementById("pw");var date = document.getElementById("date").value;var gender = document.getElementById("gender");var name = document.getElementById("name");var number = document.getElementById("number"); btn.onclick=function(){ if(gender.checked) gender="m"; else gender="f"; $.ajax({ url: 'register.php', type: 'POST', data: { email: email.value, pw: pw.value, date: date, gender: gender, name: name.value, number: number.value },繼續(xù)發(fā)送 null 作為名稱值。有什么問題?
1 回答

holdtom
TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊
您應(yīng)該創(chuàng)建一個(gè)像這樣的 FormData 對(duì)象:
var form_data = new FormData();
并附加您的數(shù)據(jù) form_data.append("email", email.value);
然后發(fā)送表單數(shù)據(jù)對(duì)象,如下所示:
data: form_data, method: 'POST',
- 1 回答
- 0 關(guān)注
- 163 瀏覽
添加回答
舉報(bào)
0/150
提交
取消