我已经成功地使用jQuery Ajax和GET和POST方法通过Web APIJQuery的自动完成散发出奇怪的字符
不过,现在我有我需要做一个AUTOCOMPLETE
我找一个任务在几个实例中,我陷入了一些疯狂的生成的URL这是国外对我
网址:
http://localhost:11974/GetPersonInfoFromRegister?term=ad&_=1445370940988
“term”从哪里来?
“1445370940988”从哪里来?
HTML
input type="text" id="txtSearch" />
的Jquery:
$(function() {
$('#txtSearch').autocomplete({
source: function(request, response) {
$.ajax({
url: '/GetPersonInfoFromRegister',
type: 'GET',
cache: false,
data: request,
dataType: 'json',
success: function(json) {
// call autocomplete callback method with results
response($.map(json, function(name, val) {
return {
label: name,
value: val
}
}));
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
//alert('error - ' + textStatus);
console.log('error', textStatus, errorThrown);
}
});
},
minLength: 2,
select: function(event, ui) {
alert('you have selected ' + ui.item.label + ' ID: ' + ui.item.value);
$('#txtSearch').val(ui.item.label);
return false;
}
});
});
我相信“一词=广告”是在搜索中查找键和“_ = 1445370940988“是您尝试实现自动完成的输入中发送的实际文本(可能是广告编号)。总之,它是一个模拟网址。 – DinoMyte
广告确实是我输入到文本框中的文本,但1445370940988我根本不明白 –
text =“ad”非常含糊地用作搜索文本。基本上,你会看到某个类别内的项目(如广告) – DinoMyte