0

これが私のコードです:

options = { 
        source: function(request, response) {
            $.getJSON('@Url.RouteUrl("Search")', { prefixText: request.term, count : 10 }, function (retour) {

                response( retour);


            });
         }

    };
    a = $('#test').autocomplete(options);

test を検索している場合、書き込みを開始すると、オートコンプリートは t、te、tes のリクエストを行い、最後にテストします...

「test」リクエストが最初に終了するため、オートコンプリートは良好な結果を表示しますが、2 秒後に「tes」の結果が表示されます

私が書いているときに他のリクエストを中止する方法はありますか?

ありがとう

4

1 に答える 1

0

これが解決策です(calixtoに感謝します):

 if(xhr)
            {
                //kill the request
                xhr.abort();
            }

            xhr = $.getJSON('@Url.RouteUrl("Search")', { prefixText: request.term, count : 10 }, function (retour) {

                response( retour);


            });
于 2012-06-20T18:33:12.903 に答える