这是我的 PHP JSON响应
data_id: [59, 92, null]
data_type: [null, null, place]
ident: [null, null, b88b0366b9799fc6836db767d91cf733c0a512ee]
image: [b.png,c.png,a.png]
visit: [5, 3, null]
name: [China, Chinua Okeke, <span class="nowrapshit">Just Use "ch"</span>]
JQUERY (响应函数)
$(document).on('keyup','.search',function(){
var q = $(this).val();
$.post('resource/php/search.php',{
q : q,
action : 'search'
},function(data){
var data_id = data.data_id,
name = data.name,
image = data.image,
visit = data.visit,
ident = data.ident;
$thisB.autocomplete({
source : name
}).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
console.log(item);
return $('<li class="sbSingleUiTokenLister" data_id="'+item.data_id+'" data_type="'+item.data_type+'" ident_id="'+item.ident+'"></li>' )
.data('item.autocomplete',item)
.append('<img src="'+item.image+'" />')
.append('<span class="name">'+item.name + '</span>')
.append('<span class="visits">'+ item.visit + '</span>')
.appendTo(ul);
};
},'json');
});
但上面的代码不起作用,因为item
只包含label
和value
如何完美地打印这段代码?