使用jQuery的Ajax警报无法正常工作

时间:2013-11-08 17:48:35

标签: php jquery ajax

问题

我的申请没有提醒

Javascript - /assests/js/global.js

$(document).ready(function(){
    $("#view").click(function(){
        var customer_id = $("#customer_id").val();

        //alert(customer_id);
        $.post('/index.php/ajax/customer_comission',
        {'customer_id' : customer_id },
        //Server responds to request
        function(result){
            alert(result);
        });
    });
});

视图

<p>
    <label for="customer_list">Customer Name</label>

    <?php echo form_dropdown('customer_id',$cust,'','id = "customer_id"'); ?>
</p>
<?php
    $btn_data = array(
        'name' => 'View',
        'id' => 'view',
        'content' => 'View Commission'
    );
?>

<?php echo form_button($btn_data); ?>

控制器 - ajax.php

class Ajax extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
    }
    function index()
    {
    }
    function customer_comission()
    {
        echo 'AJAX response !';
    }
}

0 个答案:

没有答案