Button not starting ajax call

Button not starting ajax call

Hello, My button, when clicked is not start the ajax call, I cannot work out why. This is my button: 
   
  1. <button class='btn btn-default pull-right cart-delete' onClick='event.stopPropagation();' id='$product_id'>X</button>
The reason I added onClick='event.stopPropagation();' is because my button is in a bootstrap dropdown toggle and I need to keep the dropdown "down" even after the click in the cart.
And this is my jquery code:
  1. dataType: 'json',
  2. <script>
  3. $(document).ready(function(){
  4. $(".cart-delete").click(function(){

  5. var id = $(this).parent().attr("id");
  6. alert(id);
  7. $.ajax({
  8. type: "POST",
  9. data: id,
  10. url: "resources/templates/frontend/delete-cart.php",
  11. success: function(data)
  12. {
  13. $.get('resources/templates/frontend/update-cart.php')
  14. }
  15. });
  16. event.preventDefault();
  17. });
  18. });

  19. </script>




  1. From what I have found online, adding this "event.preventDefault();" should prevent
  2. the button to reload the page but when I click it I can see a very short browser reload(fraction of a second).

Thank you in advance for your help.