TypeError:自动完成不是一个函数

时间:2015-09-17 08:38:32

标签: javascript jquery html autocomplete

我得到一个错误" TypeError:自动完成不是一个函数"在运行我的自动填充表单时。这是我的HTML代码:

<html>
    <head>
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>Track and Trace</title>
        <link href="js/jquery.mobile.theme-1.3.0.css" rel="stylesheet" type="text/css" />
        <link href="js/jquery.mobile.structure-1.3.0.css" rel="stylesheet" type="text/css" />
        <script src="js/cordova-2.4.0.js"  type="text/javascript"></script> 
        <script src="js/jquery-1.6.4.min.js" type="text/javascript"></script>
        <script src="js/jquery.mobile-1.3.0.min.js" type="text/javascript"></script>
        <script src="js/status.js" type="application/javascript"></script>
</head>
<body>
<div data-role="content"  style=" margin-top:1%; margin-bottom:10%;" align="center"> <!--Content-->
                <div class="frmSearch" style="width:75%" align="center">
                <div class="input_container">
                    <input type="text" name="jobno" id="jobno" onkeyup="autocomplete()" value=""  placeholder="Job No "  data-theme="a"/>
                    <ul id="jobno_list"></ul>
                    <input type="text" name="jobseq" id="jobseq" value="" placeholder="Job Seq No"  data-theme="a" />
                    <input type="text" name="status" id="status" value="" placeholder="Status"  data-theme="a"/>
                    <input type="text" name="remarks" id="remarks" value="" placeholder="Remarks"  data-theme="a"/>
                    <button onClick="javascript: validate(); " >Save</button>
                    <button type="reset" onClick="javascript: reset(); " >Reset</button>
                </div>
            </div>
                </div>


</body>
</html>

JavaScript功能:

function autocomplete() {
    var min_length = 0; // min caracters to display the autocomplete
    var keyword = $('#jobno').val();
    if (keyword.length >= min_length) {
        $.ajax({
            url: '192.168.0.102/ipack/refresh.php',
            type: 'POST',
            data: {keyword:keyword},
            success:function(data){
                $('#jobno_list').show();
                $('#jobno_list').html(data);
            }
        });
    } else {
        $('#jobno_list').hide();
    }
}

以下是我的php文件:

<?php
    header('Access-Control-Allow-Origin: *');
    include 'dbconnection.php';

    $keyword = '%'.$_POST['keyword'].'%';
    $sql = "SELECT JOBNO FROM PRTJOBHD WHERE JOBNO LIKE (:keyword) ORDER BY JOBNO ASC";
    $query = $pdo->prepare($sql);
    $query->bindParam(':keyword', $keyword, PDO::PARAM_STR);
    $query->execute();
    $list = $query->fetchAll();
    foreach ($list as $rs) {
    // put in bold the written text
    $jobno = str_replace($_POST['keyword'], '<b>'.$_POST['keyword'].'</b>', $rs['JOBNO']);
    // add new option`enter code here`
    echo '<li onclick="set_item(\''.str_replace("'", "\'", $rs['JOBNO']).'\')">'.$jobno.'</li>';
?>

任何人都可以帮助我解决这个问题。提前谢谢。

0 个答案:

没有答案