ajax和js在chrome中工作,但在mozilla和IE(codeigniter)中无法正常工作

时间:2013-06-03 17:56:18

标签: javascript ajax codeigniter google-chrome mozilla

我在codeigniter的网站上做自动完成系统。但我有问题。我可以在Chrome中使用此功能,但在Mozilla和IE中不起作用。例如,在chrome中打开itens会导致它们在下拉列表中查询,并且mozilla和IE显示" 2结果可用,使用向上和向下箭头键进行导航。"验证屏幕截图

视图(autoComplete_v.php):

    <head>
    <link href="../../css/ui-lightness/jquery-ui-1.10.3.custom.css" media="screen" type="text/stylesheet" rel="stylesheet" />
</head>
<body>

    <form>
        <label for="search">Search</label>
        <input id="search" type="text"/>
        <input id="hiddenurl" type="hidden">
        <input type="submit" value="submit"/>
    </form>

    <script src="<?php base_url();?>../../js/jquery-1.9.1.js" type="text/javascript"></script>
    <script src="<?php base_url();?>../../js/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>
    <script src="<?php base_url();?>../../js/autocomplete.js" type="text/javascript"></script>

js文件(autocomplete.js):

$(document).ready(function(){
 $('#search').keypress(function(e){
        if(e.which == 13)
            {
                e.preventDefault();
            }
            var searched = $('#search').val()
            var fullurl = $('#hiddenurl').val() + '../autoComplete_c/getResult/' + searched
        $.getJSON(fullurl,function(result){
           //display suggestion code goes here
           var elements = [];
           $.each(result, function(i, val){
               elements.push(val.referencia)
           })
           $('#search').autocomplete({
               source : elements
           })
        })             
    });
});

控制器(autoComplete_c.php):

public function getResult($referencia){
     if(!empty($referencia) || isset($referencia))
     {
         $this->db->select('referencia');
         $this->db->like('referencia', $referencia);
         echo json_encode( $this->db->get('produto_servico_tbl')->result());
     }
}

Chrome:enter image description here

Mozilla和IE:

enter image description here

0 个答案:

没有答案