我試圖使用使用Chrome控制檯下面發送一個Ajax請求到服務器:JQuery Ajax語法錯誤?
$.ajax({
url: 'http://www.adidas.co.uk/on/demandware.store/Sites-adidas-GB-Site/en_GB/Cart-MiniAddProduct',
data: {
"request": "ajax",
"Quantity": "1",
"g-recaptcha-response": "redacted",
"responseformat": "json",
"sku": "AQ5934",
"pid": "AQ5934_660"
},
method: 'POST',
crossDomain: true,
contentType: 'application/x-www-form-urlencoded',
xhrFields: {
withCredentials: true
},
complete: function(data, status, xhr) {
console.log(status);
console.log(data);
}
});
然而,我發現了以下錯誤:
Uncaught TypeError: $.ajax is not a function
at <anonymous>:1:3
我導致相信這個問題是由於語法錯誤,我找不到在下面的方法中的語法錯誤,有人可以幫我找到它嗎?
你是如何加載jQuery腳本? – winseybash
不應該因爲我使用的是Chrome控制檯 –
jQuery是否在您使用控制檯檢查的頁面上加載? – winseybash