增量在Codeigniter中不能通过ajax工作

时间:2013-12-02 14:30:27

标签: javascript php jquery ajax codeigniter

这是我的代码

查看----

它是整个片段的一部分 -

<?php

                foreach ($popular_projects as $row) {
                    ?>

                    <dl class="dl-horizontal">
                        <p><h5><a class="popular_project_a" id="<?php echo $row->project_thesis_id; ?>"
                                  href=""><?php echo $row->title; ?></a>
                        </h5></p>
                    </dl>
                <?php
                }
            ?>

的JavaScript --------

容器是整个容器div的类,单击正在运行,但是ajax显示错误,其中包含id(project_thesis_id)

$('.container').on('click', ".popular_project_a", function (e) {
    event.preventDefault();

    var project_thesis_id = $(this).attr('id');
    alert(project_thesis_id );
    change_popularity(project_thesis_id);


    var path = window.location.origin;

    if(path=='http://localhost'){

        window.location.replace(path+'/iit/about_iit/view_project/'+project_thesis_id);
    }else{
        window.location.replace(path+'/about_iit/view_project/'+project_thesis_id);
    }
});

function change_popularity(project_thesis_id){
    alert(project_thesis_id);
    $.ajax({
        url: "about_iit/change_popularity/"+project_thesis_id,
        type: "POST",
        dataType: "json",

        success: function (success) {

            alert(success[0].total_view);

        },
        error:function(){
            alert('error');
            alert(project_thesis_id);
        }


    });
}

控制器---------

public function change_popularity($project_thesis_id)
        {
            $this->about_iit_model->update_popularity($project_thesis_id);

            echo(json_encode($this->about_iit_model->get_specific_project($project_thesis_id)));

        }

模型------

function update_popularity($project_thesis_id){
    $this->db->where('project_thesis_id', $project_thesis_id);
    $this->db->set('total_view', 'total_view+1', FALSE);
    $this->db->update('project_thesis');

}

javascript轻松警告id(project_thesis_id)。但是ajax没有更新表。表的名称和属性是正确的。为什么不工作?任何的想法?请...

0 个答案:

没有答案