1

I want to remove all products in my card without page refresh. I created and eventlistener, it fires when form submited. But it's now working I expecte, gives me that error.

const deleteCartItems = document.getElementById('deleteAllProduct');

deleteCartItems.addEventListener('submit',deleteAllCartItem)

function deleteAllCartItem(e) {
    $.ajax({
        type: 'DELETE',
        url: "/cart/delete-products",
        context: document.body,
        success: function(){
            Flash.success("Products successfully deleted");
        }
    });
    e.preventDefault();
}
Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
  • Does it really say `DOM.addEventListener(…)`? That error isn’t possible with the code you’ve shown. Please post a [mcve]. – Sebastian Simon Jan 21 '18 at 15:58
  • @Xufox due to ";" I guess, it working right now :? –  Jan 21 '18 at 16:24
  • 1
    If it was due to a `;`, then you definitely failed to accurately demonstrate the problem with your code example. Next time, verify that your reduced example actually exhibits the problem you describe. –  Jan 21 '18 at 16:26
  • Well, actually I dont.. https://imgur.com/a/71LRG –  Jan 21 '18 at 16:35

0 Answers0