所以,我有这个请求:
var searchResults = new Array();
var ajaxRequest = function (value, type) {
if (typeof(type) === "undefined")
type = "default";
var ajaxData = {
"title" : value,
"limit" : getLimit(),
"offset" : getOffset()
}
recentRequest = $.ajax({
type : "GET",
url : getAjaxUrl(),
dataType : "json",
contentType : "application/json; charset=utf-8",
data : ajaxData,
beforeSend : function (data)
{
if (searchResults[value] != undefined)
{
(type === "pagination") ? ajaxSuccessPagination(searchResults[value], ajaxData) : ajaxSuccess(searchResults[value], ajaxData);
return false;
}
},
success : function (data) {
searchResults[value] = (data);
(type === "pagination") ? ajaxSuccessPagination(data, ajaxData) : ajaxSuccess(data, ajaxData);
},
error : function (data) {
ajaxError(data);
}
});
}
如果您键入'usb'并将其删除,请输入'pencil',它会在您填写铅笔时首先显示usb结果,现在我想制作它以便检查结果是否为与当前输入的值相同。谁能帮我?
由于
答案 0 :(得分:0)
我仍然不确定这些是否是你真正想要的,但无论如何,
1)如果您有关键字词典(您希望仅显示有效关键字的搜索结果):
2)如果你没有关键词典,你只想避免空白搜索结果:
答案 1 :(得分:0)
设法让它工作,无论如何,谢谢
var ajaxRequest = function (value, type) {
if (typeof(type) === "undefined")
type = "default";
var ajaxData = {
"title" : value,
"limit" : getLimit(),
"offset" : getOffset()
}
$.ajax({
type : "GET",
url : getAjaxUrl(),
dataType : "json",
contentType : "application/json; charset=utf-8",
data : ajaxData,
beforeSend : function (data)
{
if (searchResults[value] != undefined)
{
(type === "pagination") ? ajaxSuccessPagination(searchResults[value], ajaxData) : ajaxSuccess(searchResults[value], ajaxData);
return false;
}
},
success : function (data) {
searchResults[value] = (data);
if (document.getElementById('search').value == data.searched)
{
(type === "pagination") ? ajaxSuccessPagination(data, ajaxData) : ajaxSuccess(data, ajaxData);
}
},
error : function (data) {
ajaxError(data);
}
});
}