Php 自动完成dos不显示传递自定义值的结果
我正在尝试将自定义值传递给autocomplete,因此: 我的自定义工作值基于 使用默认源(如文档):Php 自动完成dos不显示传递自定义值的结果,php,jquery,arrays,autocomplete,Php,Jquery,Arrays,Autocomplete,我正在尝试将自定义值传递给autocomplete,因此: 我的自定义工作值基于 使用默认源(如文档): $("#inpPesqCli").autocomplete({ source: "ajax/search.php", minLength: 2, autoFocus: true }); firebug返回以下示例: [... { "id": "29083", "label": "SOME ONE 2", "value":
$("#inpPesqCli").autocomplete({
source: "ajax/search.php",
minLength: 2,
autoFocus: true
});
firebug返回以下示例:
[...
{ "id": "29083", "label": "SOME ONE 2", "value": "SOMEONE WITH LELE" },
{ "id": "19905", "label": "SOME ONE", "value": "SOMEONE WITH LALA"},
...]
工作很完美,结果就出来了
当我尝试设置一些自定义值时:
$("#inpPesqCli").autocomplete({
source: function( request, response ) {
$.ajax({
url: "ajax/search.php",
dataType: "jsonp",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: request.term
},
success: function( data ) {
response( $.map( data.geonames, function( item ) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name
}
}));
}
});
},
minLength: 2,
autoFocus: true
});
firebug返回给我的是完全相同的数组结果:
[...
{ "id": "29083", "label": "SOME ONE 2", "value": "SOMEONE WITH LELE" },
{ "id": "19905", "label": "SOME ONE", "value": "SOMEONE WITH LALA"},
...]
但是,问题是,当我通过自定义计算时,结果的dosent显示出来
php:
不知道我遗漏了什么。设置ajax type=GET,也许可以工作,默认情况下数据发送类型是POST
$("#inpPesqCli").autocomplete({
source: function( request, response ) {
$.ajax({
url: "ajax/search.php",
dataType: "jsonp",
type : "GET",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: request.term
},
success: function( data ) {
response( $.map( data.geonames, function( item ) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name
}
}));
}
});
},
minLength: 2,
autoFocus: true
});
$("#inpPesqCli").autocomplete({
source: function( request, response ) {
$.ajax({
url: "ajax/search.php",
dataType: "jsonp",
type : "GET",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: request.term
},
success: function( data ) {
response( $.map( data.geonames, function( item ) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name
}
}));
}
});
},
minLength: 2,
autoFocus: true
});