duanliao6789 2015-07-16 18:01
浏览 41

带有ajax和codeigniter的错误500

I have a problem with calling ajax on my view on codeigniter website. Ajax is calling method in controller on same project. I have ajax search, which is work correctly. When I chose one of results, he open a new tab and show me a detail information from database. In some cases when I click on some results(I didn't find rule when it will be happening), ajax return me a 500 error, without go into controller method, but when I refresh the page (F5) he shows me a correct result. Did someone have a same problem, or can help me to fix it? Here is my ajax call:

<script>
$(document).ready(function() {
    $.ajax({
        type: 'POST',
        url: '<?=site_url('index/ajax_read_details')?>',
        dataType: 'json',
        cache: false,
        async:true,
        data: {'param':'<?=$selected?>'},
        beforeSend: function (xhr) {
            $('#loading').show();
        },
        success: function (data) {
            $('#loading').hide();
                var details = '<tr>' +
                    '<td>'+data['title']+'</td> '+
                    '<td>'+data['code']+'</td>' +
                    '</tr>';
                $('#data >tbody').append(details);
            })
        },
        error: function(jqXHR, textStatus, errorThrown){
            alert('Error: '+ errorThrown);
        }
    });
});
</script>

I know now that he didn't go into controller method "ajax_read_details" in index controller in case when it give me an 500 error.But when I refresh, he go into that method and do it correctly job. In both cases, he send a same values but in first he didn't return values, after refresh page he give me a values :(

Short controller method is:

public function ajax_read_details()
{
    $param = $this->input->post('param');

    echo json_encode(array('title' => $param, 'code'=>param));
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 一道python难题
    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度