请问这段表单提交的小程序代码如何修改
发布于 5 年前 作者 lifan 1701 次浏览 来自 问答

<form bindsubmit=“formSubmit” bindreset=“formReset”>

<view class=“xiaobiao”>

<input type=“text” bindblur=‘no_focus’ name=‘dhhm’ bindfocus=“focus” placeholder=“请输入您的电话号码”/>

</view>

<view class=“tijiao”>

<button type=“primary” formType=“submit”>立即申请</button>

js:

formSubmit: function (e) {

var formData = e.detail.value;

console.log(formData)

wx.request({

url: ‘php地址’,

data: {

dhhm: formData.tel

},

header: {

‘content-type’: ‘application/x-www-form-urlencoded’

},

success: function (res) {

console.log(res);

},

fail: function () {

console.log(‘request from fail’)

},

})

},

这个表单提交不到数据库也提交不到后台 不知道什么原因 请大神帮忙修改

2 回复

data: {

dhhm: formData.dhhm

},

这个是什么意思?不太懂

注意加下划线的

wxml:

<form bindsubmit=“formSubmit” bindreset=“formReset”>

<view class=“xiaobiao”>

<input type=“text” bindblur=‘no_focus’ name=‘dhhm’ bindfocus=“focus” placeholder=“请输入您的电话号码” />

</view>

<view class=“tijiao”>

<button type=“primary” formType=“submit”>立即申请</button>

</view>

</form>


js:

formSubmit: function (e) {

var formData = e.detail.value;

console.log(formData)

wx.request({

url: ‘php地址’,

data: {

dhhm: formData.dhhm

},

header: {

‘content-type’: ‘application/x-www-form-urlencoded’

},

success: function (res) {

console.log(res);

},

fail: function () {

console.log(‘request from fail’)

},

})

},

回到顶部