added delete function on store item

This commit is contained in:
franknstayn
2020-01-25 20:12:01 +08:00
parent c392e3f207
commit 5c2bc3e780
5 changed files with 63 additions and 0 deletions

View File

@@ -1582,6 +1582,43 @@
readURL(this, $id);
});
$("#btn_delete_store_id").click(function() {
var id = $(this).data('id');
var result = confirm("Are you want to delete?");
if (result) {
//Logic to delete the item
$.ajax({
type : 'POST',
url : "{{ url('user/store-items/delete') }}",
data : {
id: id
},
beforeSend:function(xhr){
var token = $('meta[name="csrf_token"]').attr('content');
if (token) {
return xhr.setRequestHeader('X-CSRF-TOKEN', token);
}
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest');
},
success : function(response){
// console.log(response);
if(response.success){
alert(response.message);
window.location = "{{ url('user/store-items') }}";
}else{
alert("Something went wrong. Please try again!");
location.reload();
}
}
});
return false;
}
return false;
});
}); //end document ready
// function