我想知道如果刪除工作像添加,但它沒有。即時通訊使用fetch方法我不是在反應熟悉的AJAX,所以我不能清楚地確定什麼是錯我的代碼如何做阿賈克斯刪除反應
所以這裏是我的代碼的onclick刪除
deleteEmployee(id) {
jQuery.support.cors = true;
fetch('http://localhost:5118/api/employeedetails/DeleteEmployeeDetail/'+ id, {
method: 'GET'
}).then(function(response) {
// history.go(0);
var jsonReturnedValue = [...this.state.jsonReturnedValue];
this.setState({jsonReturnedValue})
}).catch(function(err) {
// Error :(
});
}
這是表
< div className="container">
<h1> Listof Employees </h1>
<button className ='btn btn-warning right ' data-toggle="modal" data-target="#AddEmployee"> Add an Employee</button>
<table className= "table table-bordered" id="result">
<tbody>
<tr>
<th>ID</th>
<th>Name</th>
<th>Address</th>
<th>Update</th>
<th>Delete</th>
</tr>
{jsonReturnedValue.map((d,i) => this.renderItem(d,i))}
</tbody>
</table>
</div>
代碼對於其中按鈕位於
renderItem(d, i) {
return <tr key={i} >
<td> {d.Employee_ID} </td>
<td>{d.Employee_Name}</td>
<td>{d.Address }</td>
<td><center><button className ="btn btn-info" onClick={this.handleOnclick.bind(this, d.Employee_ID, d.Employee_Name, d.Address , d.Department)} data-toggle="modal" data-target="#UpdateEmployee">Edit</button></center></td>
<td><center><input type="submit" className ="btn btn-danger" onClick={this.deleteEmployee.bind(this, d.Employee_ID)} value="Delete"/></center></td>
</tr>
}
PS數據的主叫
代碼: 本身是工作的代碼,以便在控制檯說,沒有什麼是錯的,但我想它,當我點擊它表重裝
**開發人員**工具控制檯或網絡選項卡中的任何有用輸出? –
該代碼本身工作,所以它什麼都沒說,但我想要它,當我點擊它表重新加載 –
你能顯示你的反應組件嗎?不只是方法,所以我們會知道你是如何處理這個狀態的。 – ickyrr