I have this function :
function deleteDocument(e, document_id, property_id) {
e.preventDefault();
$('#editDocumentLoader').css('display', 'flex');
$.ajax({
type: "POST",
dataType: "json",
url: window.location.protocol + "/profile/property/document/delete/" + document_id,
data: {
'document_id': document_id,
'property_id': property_id,
'_token': CSRF_TOKEN
},
cache: false
}).done(function(response) {
alert(response);
if (response != "") {
try {
$('#document_table').html(response.data);
$('#editDocumentLoader').hide();
} catch (e) {
console.log(e)
}
} else {
console.log("no response");
}
}).fail(function(response) {
console.log(response);
if (response.status == 422) {
var errors = response.responseJSON;
}
});
}
In view i have this that is inside form
:
<button onclick="deleteDocument(event,{{$document->id}},{{$property->id}})"><i class="fa fa-times"></i></button>
From some reason it submit my form and then my ajax call is not working. Any suggestion why is that ?