skip to Main Content

$.ajax not working when used in ("click") event listener – Jquery ajax

This is my Javascript code: const checkbox = document.querySelector("#checkbox"); const button = document.querySelector("#button"); button.addEventListener("click", function(e){ var text = ""; if(checkbox.checked === true){ text = "Is Checked"; } $.ajax({ url: '/update_if_checked/', data: {'is_checked': text}, type: 'POST' }).done(function(response){ console.log(response); }); }); I…

VIEW QUESTION
Back To Top
Search