Javascript 如何更新reactjs fetch
我正在尝试更新我的表格行,但是它不起作用。配置文件部分没有读取输入中的数据 这是我用于更新按钮的函数Javascript 如何更新reactjs fetch,javascript,asp.net,api,reactjs,web,Javascript,Asp.net,Api,Reactjs,Web,我正在尝试更新我的表格行,但是它不起作用。配置文件部分没有读取输入中的数据 这是我用于更新按钮的函数 handleUpdate(id, name, address,department){ debugger jQuery.support.cors = true; function createNewProfile(profile) { const formData = new FormData(); formData.append
handleUpdate(id, name, address,department){
debugger
jQuery.support.cors = true;
function createNewProfile(profile) {
const formData = new FormData();
formData.append('Employee_Name', profile.name);
formData.append('Address', profile.address);
formData.append('department', profile.depatment);
return fetch('http://localhost:5118/api/employeedetails/PutEmployeeDetail/' +id, {
method: 'POST',
body: formData
})
.then(response => response.json())
}
createNewProfile(profile)
.then((json) => {
// handle success
})
.catch(error => error);
}
这是表单、输入和按钮所在的部分
<div className="modal fade" id="UpdateEmployee" role="dialog">
<div className="modal-dialog">
<div className="modal-content">
<div className="modal-header">
<button type="button" className="close" data-dismiss="modal">×</button>
<h4 className="modal-title">Update Employee</h4>
</div>
<form onSubmit={this.handleUpdate}>
<div className="container">
<div className="modal-body">
<table>
<tbody>
<tr>
<td>Name</td>
<td>
<input type="text"
name="Employee_Name"
value={this.state.Employee_Name}
onChange={(e) => this.handleChange(e)}/>
</td>
</tr>
<tr>
<td>Address</td>
<td>
<input type="text"
name="Address"
value={this.state.Address}
onChange={(e) => this.handleChange(e)}/>
</td>
</tr>
<tr>
<td>Department</td>
<td>
<input type="text"
name='Department'
value={this.state.Department}
onChange={(e) => this.handleChange(e)}/>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div className="modal-footer">
<input type="submit" className="btn btn-info" onClick = { this.handleUpdate.bind(this, this.state.Employee_ID , this.state.Employee_Name ,this.state.Address ,this.state.Department)} value =" Add Employee"/>
<button type="button" className="btn btn-default" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
&时代;
更新员工
名称
this.handleChange(e)}/>
地址
this.handleChange(e)}/>
部门
this.handleChange(e)}/>
接近
我看到一个输入错误-HandleUpdate,它被称为这样-HandleUpdate你能检查一下吗?哦,等等,我忘了编辑那个部分,但我已经在代码中更改了那个部分,你只能写这个-这个.HandleUpdate.bind(这个),你可以使用这个.state.name访问其他东西,无需通过他们我是如何尝试的,但我也有一个输入,用于在同一个pge上添加新员工,这就是为什么它使it很难读取它,为什么你有一个函数在另一个函数中,从哪里获得配置文件值?这让人困惑