hello , i am relatively new at javascript and i am experiencing a problem with an Ajax ‘delete’ , can someone tell me what the problem could be? thanks!
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!-- input form -->
<form>
Beds:<br>
<input type="text" name="firstname" id="beds" value="">
<br>
Baths:<br>
<input type="text" name="lastname" id="baths" value="">
<br><br>
<input type="submit" value="Submit" id="submit">
</form>
<button id="refresh">refresh</button>
<div class="row" id="propertyContainer">
<!-- content loads here -->
</div>
<!-- javascript/jq -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="js/get.js"></script>
<script src="js/submit.js"></script>
<script src="js/delete.js"></script>
</body>
</html>
// this is the ajax delete method that is giving me issues
$('body').on('click','.deleteBtn', function(e){
var id = $(e.target).attr('data-id');
alert('gelukt')
deleteProp(id);
})
function deleteProp(id){
$.ajax({method:'DELETE',url:"http://5ca1e35cc1b53400149acb87.mockapi.io/properties/"+id})
.done(function(){
// getProperties();
var elementToRemove = document.getElementById("prop" + id);
elementToRemove.parentElement.removeChild(elementToRemove);
})
}```