When i click on the button, this error is blow up! help pls When i click on the button, this error is blow up! help pls
TypeError: $.ajax is not a function
$(document).on('click', '.item_add', function(e){
e.preventDefault();
product_id = $(".product_id").html();
product_name = $(".product_name").html();
product_price = parseFloat($(".item_price").html())
product_size = $(".bann-size").val();
url = '/basket_adding/'
var data = {};
data.product_id = product_id
data.product_name = product_name
data.product_price = product_price
data.product_size = product_size
$.ajax({
url: url,
type: 'POST',
data: data,
cache: true,
success: function(data){
console.log("OK");
},
error: function(data){
console.log(data + "ERROR")
alert("Something wrong, try again!")
location.reload();
}
});
});
Many pages send AJAX requests to a server. Because this relies on the cooperation of the server and the network between the client and the server, you can expect these AJAX errors: Your JavaScript program receives an error response instead of data; Your program has to wait too long for the response.
Ajax is a programming concept. Below are some ways to make Ajax call in JavaScript. Approach 1: In this approach, we will use the XMLHttpRequest object to make Ajax call. The XMLHttpRequest() method which create XMLHttpRequest object which is used to make request with server.
AJAX stands for Asynchronous JavaScript And XML. In a nutshell, it is the use of the XMLHttpRequest object to communicate with servers. It can send and receive information in various formats, including JSON, XML, HTML, and text files.
What is AJAX? AJAX = Asynchronous JavaScript and XML. In short; AJAX is about loading data in the background and display it on the webpage, without reloading the whole page. Examples of applications using AJAX: Gmail, Google Maps, Youtube, and Facebook tabs.
It sounds like you could be using jquery slim which doesn't have ajax support. Use:
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
for ajax support
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With