我显示表上的反应,我从PHP api获取。该表包含每行上具有删除和编辑按钮的名称。表显示,但删除按钮给出一个错误
:未捕获语法错误:输入意外结束。
以下是我在php api中的按钮代码:*
$response['table'] .= "<td><button id='delete_id' type='submit' data-id='".$row['id']."'onClick='{this.handleDelete('".$row['id']."')}'>DELETE</button></td>";
下面是处理删除的函数代码:
handleDelete(id) {
fetch('http://localhost/task5/ReactApi/deleteUser', {
method: 'POST',
body: JSON.stringify({id: id}),
headers: {"Content-type": "application/json"}
}).then(res => res.json())
.then((result) => {
if(result.status === 'success'){
window.location = '/home';
}
});
}
基于文章中列出的稀缺信息,我猜post API没有返回任何内容(就像许多post调用一样),并且=