Code: Select all
$('.qty').keyup(function () {
var $me = $(this),
$parent = $me.parent('div'),
total = parseInt($me.attr("data-price"));
if (isNumber($me.val()) && $me.val() > 0) {
total = total * $me.val();
}
$parent.find('.price').html(total);
updateTotal();
});
function isNumber (n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function updateTotal () {
var total = 0;
$('.qty').each(function () {
var $me = $(this);
if (isNumber($me.val()) && $me.val() > 0) {
total += $me.val() * parseInt($me.attr("data-price"));
}
});
$('#total').text(total);
var toSend= {
total: total
};
$.ajax({
type:'POST',
url:'./s.php',
data: toSend,
success: function(data){
alert(data);
}
});
}
updateTotal();
Code: Select all
Notice: Undefined index: total in C:\xampp\htdocs\test\s.php on line 3
Datele afisate de catre script in pop-up la succes sunt corecte, insa nu sunt trimise catre PHP.
Care ar putea fi problema?