我有一张发票,当我想编辑时,我希望能够删除一些行,要么在数据库中找到该行,要么添加该行,但单击“添加”按钮。所以我必须根据这个条件删除这个行如果在数据库中找到,则删除行删除/删除行(如果添加了新行)(无需签入 DB,因为您添加了新行)以下是我的发票,显示行包含来自DB的数据,而行没有数据(新增)所以我已经删除了在DB中找到的行,并且我想按照我的以下代码应用第二个条件。 $(document).ready(function () { $("body").on("click",".remove",function(e){ var last=$('#tdy tr').length; if(last==1){ alert("you can not remove last row, Otherwise Delete The Order Number!"); } //here i tried the second condition else if(iddata=null){ $(this).parent().parent().remove(); } else{ if(!confirm("Do you really want to delete this?")) { return false; } e.preventDefault(); // var id = $(this).attr('data-id'); var id = $(this).data("id"); var token = $("meta[name='csrf-token']").attr("content"); var url = e.target; $.ajax( { url: "Loading/"+id, //or you can use url: "company/"+id, type: 'DELETE', data: { "id": id, "_token": token, }, success: function (response){ if ( data['success'] ) { alert(data['success']); location.reload(); } } }); return false; } });我怎么能解决这个问题,有些人可以帮助我
添加回答
举报
0/150
提交
取消
