0

AJAX 経由で呼び出される Web サービス ファイルからユーザー データのリストを取得しようとしています。これが私のコードです:

      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

<script type="text/javascript">
    var param;
    var resultarr;

    $(document).ready(function () {    
        param = document.getElementById('MainCT_dtvJobVac_PIC').value;
        // Load countries then initialize plugin:
        $.ajax({
            type: 'POST',
            contentType: 'application/json;',
            data: '{keyword:' + JSON.stringify(param) + '}',
            dataType: 'json',
            url: 'SvcADUser.asmx/GetADUserList',
            success: function (result) {
                //alert(result.d)
                resultarr = result.d;
            }
        })

        // Initialize autocomplete with local lookup:

        $('#MainCT_dtvJobVac_PIC').autocomplete({                  
            source: resultarr
        });
    });
</script>

resultarrこの値を持つ配列を出力します:

[ "Administrator", "Guest", "krbtgt", "phendy" , "Genin" ,  "Hendra" ,  "andri" ]

これをスローします:

TypeError: this.source は関数ではありません [このエラーで中断] this.source( { term: value }, this._response() );

ここで何を修正する必要がありますか? 私はこれに2日間苦労しています。助けていただければ幸いです。

4

2 に答える 2

4

オートコンプリートの初期化を ajax 成功コールバック内に移動します。

success: function (result) {
    //alert(result.d)
    resultarr = result.d;
    $('#MainCT_dtvJobVac_PIC').autocomplete({
         source: resultarr
    });
}
于 2013-05-14T12:30:27.450 に答える