I have HTML code like this:
<button class="btn btn-large btn-primary" type="button" onclick="addtocart();">Tambah Item</button>
And I want to execute this jQuery function:
function addtocart() {
var url = '<?php echo BASE_URL."modul/penjualan_barang/content/cart.php"?>'
$.post(url+'?act=addcart',{barcode:$(".combo-value").val()},function(result){
alert(result);
if (result.success){
$.messager.alert('Benar','Terdapat kesalahan ketika proses menginput, coba refresh halaman anda','error');
} else {
$.messager.alert('Kesalahan','Terdapat kesalahan ketika proses menginput, coba refresh halaman anda','error');
}
},'json');
}
But I can’t get any result for that function, so I don’t know if it’s working or not.
Any suggestion please???
The callback only executes when the POST request returns HTTP 200 (success). You must be getting an error code response from the server.
The Chrome plugin “REST Console can help debug the response.