我有一張發票,當我想編輯時,我希望能夠刪除一些行,要么在數據庫中找到該行,要么添加該行,但單擊“添加”按鈕。所以我必須根據這個條件刪除這個行如果在數據庫中找到,則刪除行刪除/刪除行(如果添加了新行)(無需簽入 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; } });我怎么能解決這個問題,有些人可以幫助我
使用 ajax 和拉拉維爾刪除動態行
叮當貓咪
2022-09-29 15:29:48