根據標題我只面臨一次部署的性能問題。它是一個ASP.NET MVC5站點,並部署在Azure上。我們正在講話vs幾秒鐘:/jQuery autocomplete - 緩慢服務器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