我试图更新我的表行,但它不起作用,配置文件部分没有读取输入内的数据
这是我用于更新按钮的功能
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>