About the remote return of the JSON data display, the same code, if the local write JSON string data, plug-in display there is no problem, once replaced by ULR way to read the same data, plug-ins can not display the problem properly.
The occasional search for information today to find a question on the CSDN, is the same problem
Http://topic.csdn.net/u/20090703/14/8d349262-8ca1-4bf5-998d-3a0712412149.html
There's an expert in the solution
$ ("#autocomplete"). AutoComplete ("Data.aspx", {
minchars:0,
Max:15,
WIDTH:200,
Scroll:false,
SCROLLHEIGHT:500,
Need to convert data into JSON data format
Parse:function (data) {
if (Data! = "") {
Return $.map (eval (data), function (row) {
return {
Data:row,
Value:row.name,
Result:row.name + "<" + row.to + ">"
}
});
}
},
Formatitem:function (data, I, total) {
Return "<div style= ' Float:left ' >" +data.name+data.to+ "</div>"
},
Formatmatch:function (data, I, total) {
return data.name;
},
Formatresult:function (data, value) {
return data.name;
}
}). result (function (event, data, formatted) {
$ ("#twoColum_abbr"). Val (data.to);
});
After the data is returned, it is time to process
The key point is
You need to convert data to JSON data format, note that you must determine if data is empty, otherwise out of the ordinary, the following red callout
Parse:function (data) {
if (Data! = "") {
Return $.map (eval (data), function (row) {
return {
Data:row,
Value:row.name,
Result:row.name + "<" + row.to + ">"
}
});
}
},
This way, you can manipulate the data normally.
jquery's autocomplete plugin's remote URL takes JSON data out of the question