見出しごとに私は性能が一度だけ問題に直面しています。 ASP.NET MVC5サイトで、Azureにデプロイされています。私たちは数秒で話しています:/jQueryオートコンプリート - 遅いサーバーvsローカル
私はこの問題を解決するのに役立つビデオを準備することができます。 ませんJSエラーが悲しげにスローされます:/
ライブ働くことを示す画像である、それは最終的に...長くない場合は7/8秒などの後に示します。 コード入ってくる...
$(document).ready(function() {
$("#SerialSearch").autocomplete({
autoFocus: true,
//delay: 0,
minLength: 2, // minimum length to trigger suggestions
select: function(e, ui) { // define select handler
//alert(ui.item.value);
//hitting enter key on selected item works, mouse clicking after 609 on V609xxx will submit 609 sadly
//With this I override the problem
$('#SerialSearch').val(ui.item.value);
//alert('here');
$(this).parents('form').submit();
},
source: function (request, response) {
@*var modelDataJSON = '@Html.Raw(Json.Encode(Model))';*@
var check = @Html.Raw(val);
//var modelDataJSON = JSON.stringify(check);
$.ajax({
url: "/Devices/DeviceSearch",
type: "POST",
dataType: "json",
data: { Prefix: request.term, model: check },
success: function (data) {
//alert('success');
response($.map(data, function (item) {
return { label: item.SerialNumber, value: item.SerialNumber };
}))
}
})
}
//messages: {
// noResults: "", results: ""
//}
});
})
CSHTML:
@{
ViewBag.Title = "Devices";
Layout = "~/Views/Shared/_Layout.cshtml";
//var val = Json.Encode(Model);
//Using viewdata to load in mem entire device list
var val = Json.Encode(@ViewData["FullDeviceList"]);
}
@using (Html.BeginForm(FormMethod.Get))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
<div class="form-group">
<div class="col-md-12">
@Html.EditorFor(model => model.SerialSearch, new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>
</div>
}
[最小、完全で、検証可能な例](http://stackoverflow.com/help/mcve) – Liam
あなたの質問は何ですか? – JohnH
うわー、あなたたちは速いです:)右に来てください – David