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

How do I combine javascript variables into a object – Jquery ajax

I need to combine all variables in one object: $.get("https://www.virginmegastore.ae/en/gaming/playstation/playstation-games/sonic-forces---ps4/p/714792", function (data) { var productNamePost=$("[name='productNamePost']").val(); var productCodePost=$("[name='productCodePost']").val(); var bg = $('.pdp_image-carousel-image.js-zoomImage-mobile').css('background-image'); var productPrice=$(".price__container > .price__value > .price__number").text(); var url = window.location.href; console.log(url); }); Sorry the question was unclear,i was need…

VIEW QUESTION
Back To Top
Search