Я создаю событие, но не могу обнаружить его с помощью Ajax. Я работаю над Codeigniter, и у меня есть следующий код: -
View.php
$("#promocode").on("input",function(){
console.log('handler detected');
var valueModel = $(this).val();
$.ajax({
url : "bookings/getVCode",
type: "post",
data: {"valueModel":valueModel},
success : function(data){
// console.log(data);
$("#msg").html(data);
},
});
});
Promo Code
Мой контроллер:
Bookings.php
function getVCode()
{
$data = $this->NewQuoteModel->checkVoucherexist();
$option ="";
if(count($data) > 0){
$option .="
Your Voucher is Valid!
";
} else {
$option .= "
Your Voucher is not Valid!
";
}
echo $option;
}
И мое модальное окно
NewQuoteModel.php
function checkVoucherexist()
{
$model = $this->input->post('valueModel');
$this->db->select('*');
$this->db->from('Vouchers');
$this->db->where('Name', $model);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
//echo 'No Make found';
}
}
Подробнее здесь: https://stackoverflow.com/questions/524 ... onsole-log