JQuery Error for Ajax
Hy i have problem getting value in ajax, I get error message in script
xhr.send( ( options.hasContent && options.data ) || null );
On what is concern this error. JQuery code is :
$(document).ready(function(){
function refreshSmallBasket(){
$.ajax({
type: 'POST',
url:'mod/basket_small_refresh.php',
dataType:'json',
success: function(data){
$.each(data, function(k, v){
$("#basket_left ." + k + " span").text(v);
});
},
error: function(data){
console.log(data.status + " " + data.statusText);
}
});
}
//if there class with name add_to_basket
if($(".add_to_basket").length > 0){
//on this class on click execute
$(".add_to_basket").click(function(){
//this click with this class
var trigger = $(this);
//add attribute rel from link
var param = trigger.attr("rel");
//split atribute with _ example rel= 2_3 we spleet 2 and 3
var item = param.split("_");
$.ajax({
type: 'POST',
url:'mod/basket.php',
dataType: 'json',
data: ({ id : item[0], job : item[1]}),
success: function(data){
var new_id = item[0] + '_' + data.job;
if(data.job !=item[1]){
if(data.job == 0){
trigger.attr("rel", new_id);
trigger.text("Remove From Basket");
trigger.addClass("red");
}
else{
trigger.attr("rel", new_id);
trigger.text("Add To Basket");
trigger.removeClass("red");
}
refreshSmallBasket();
}
},
error:function(data){
console.log(data.status + " " + data.statusText);
}
});
return false;
});
}
});
|