当要搜索客户名称时,jQuery会自动附加cstmr-prfsnl-ajax-search.php?term=[search value]
,但我想用客户替换术语。请帮帮我。
$("#ccpd_name").autocomplete({
source: "cstmr-prfsnl-ajax-search.php",
minLength: 1
});
答案 0 :(得分:1)
您可以这样使用:
$("#ccpd_name").autocomplete({
source: function (request, response) {
$.ajax({
url: "cstmr-prfsnl-ajax-search.php",
data: { customer: request.term },
dataType: "json",
success: response,
error: function () {
response([]);
}
});
});
});
cstmr-prfsnl-ajax-search.php?customer = [search value]
答案 1 :(得分:0)
您还可以像这样省略数据字段:
$("#ccpd_name").autocomplete({
source: function (request, response) {
$.ajax({
url: "cstmr-prfsnl-ajax-search.php?customer=" + request.term,
dataType: "json",
success: response,
error: function () {
response([]);
}
});
});
});