在我的要求自动填充文本框中。我已经完成了。但有时它会显示内部服务器错误,表明时间数据未显示。充满了错误 这是我的代码如何解决它请帮助我。
$(function () {
SearchText();
});
function SearchText() {
$(".autosuggest").autocomplete({
source: function (request, response) {
var _reqObj = new Object();
_reqObj.username = document.getElementById('txtSearch').value;
_reqObj.Meth = "AB";
$.ajax({
type: "POST",
url: "../Harneedi2/api/Home",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: _reqObj,
success: function (data) {
var list = data;
if (list.length > 0) {
response($.map(list, function (item) {
return {
label: item.split('-')[0],
val: item.split('-')[1]
}
}));
}
else {
response([{ label: 'No Records Found', val: -1}]);
}
},
error: function (result) {
alert("Error...plz enter correct letter");
}
});
},
select: function (e, i) {
// $("[id$=hfspecializationID]").val(i.item.val);
// alert(i.item.val);
}
});
}
//space key disable & cut copy paste
$(function () {
$('body').on('keydown', '#txtSearch', function (e) {
console.log(this.value);
if (e.which === 32 && e.target.selectionStart === 0) {
return false;
}
});
});
//cut copy paste disable
$(document).ready(function () {
$('#txtSearch').bind('copy paste cut', function (e) {
e.preventDefault(); //disable cut,copy,paste
alert('cut,copy & paste options are disabled !!');
});
});
答案 0 :(得分:0)
请检查您提供的网址..
如果您正在使用mvc,请尝试@url.Action("Action","Controller",new{id=1})
其他查询字符串需要像/ somepage?id = 1