Я получаю неопределенное значение, когда пытаюсь получить значение купона из таблицы купонов из моей БД, но когда я получаю правильное значение в процентах или цене, это правильно, код написан на ajax, так как я новичок в ajax, помогите мне решить эта проблема.
(function() {
var path = "{{ route('validate.coupon') }}";
$('.reserve-button').click(function() {
var coupon_number = $('.coupon-number').val();
var org_price = parseInt($('#amount').val());
//alert(coupon_number);
if (coupon_number == '') {
alert("Please Enter Coupon Number");
} else {
$.ajax({
url: path,
data: {
"coupon_number": coupon_number
},
type: 'get',
success: function(result) {
if (result.percentage == 0 && result.price == 0) {
alert('Sorry Coupon Not Exists');
} else {
$("input[name='coupon']").prop('disabled', true);
$("#btn-apply-now").remove()
var disc = org_price * (result.percentage / 100.0) + result.price;
var new_price = org_price - disc;
$('.price').html('$' + new_price);
// $('#amount').val(new_price);
$('#coupon-number').val(coupon_number);
alert('!!__ Congratulations you got ' + result.percentage + '% and ' + result.price + '$ discount __!!');
$('#price_detail').append('<li class="item clearfix"><div class="title">Discount</div><span>$' + disc + '</span></li>')
}
}
});
}
});
})();