Reputation: 13
// Added dollar sign to question
$(".purchase_btn").live("click",function(){
//renew cart
$.ajax({
url: "<?=base_url()?>frontend/ncart/smallcart/",
type: "post",
async: false,
dataType: "json",
success: function(data){
$("#cart_div_item").html(data.cart);
$("#cart_div_total").html("總計:$"+data.total);
}
});
$("#cart_div_small").show();
$('#cart_div_small').aqFloater({
attach: "e",
offsetY: -150,
overlay: 10,
overlayOpacity: 0.7
});
clog("cart reinit");
});
How to use $.ajax
in live
? the $.ajax
is not working when I use live
If type change to get
it can work, but I want to use post
to get json
data.
Any idea?
Upvotes: 1
Views: 1708
Reputation: 50974
you're missing $ at the start of code!
(".purchase_btn")
it should be
$(".purchase_btn")
Upvotes: 0
Reputation: 146310
make your self an error function to catch errors:
$.ajax({
url: "<?=base_url()?>frontend/ncart/smallcart/",
type: "post",
async: false,
dataType: "json",
success: function(data){
$("#cart_div_item").html(data.cart);
$("#cart_div_total").html("總計:$"+data.total);
},
error: function(jqXHR, textStatus, errorThrown){
console.log(arguments);
}
});
Upvotes: 1
Reputation: 77996
Looks like you missed the dollar sign:
(".purchase_btn").live("click",function(){
should be
$(".purchase_btn").live("click",function(){
Upvotes: 0