我正在尝试进行AJAx调用以删除表中的行,我的函数仅在chrome中起作用,而在IE8和Firefox中不起作用
function delete_row(id)
{
if(confirm('Confirm to delete this Equipement ?')){
$.ajax
({
type:'post',
url:'edit_equipment.php',
data:{
delete_row:'delete_row',
row_id:id
},
success:function(response) {
if(response=="success")
{
var row=document.getElementById("row"+id);
row.parentNode.removeChild(row);
}
}
});
}
window.location.reload();
}
告诉浏览器启动ajax请求后,您将立即重新加载页面。这样可以阻止发送请求,或者如果正在处理则中止请求。这还会导致在加载新页面和删除(如果服务器已接收到)之间发生竞争。
您根本不需要reload
,因为您是动态删除行。只需删除
window.location.reload();
完全排成一行。
但是,如果您仍然要调用它,那么请在请求完成后再调用它:
function delete_row(id) {
if (confirm('Confirm to delete this Equipement ?')) {
$.ajax({
type: 'post',
url: 'edit_equipment.php',
data: {
delete_row: 'delete_row',
row_id: id
},
success: function(response) {
if (response == "success") {
var row = document.getElementById("row" + id);
row.parentNode.removeChild(row);
window.location.reload(); // But again, you probably don't need it
}
}
});
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句