Issue 1: The JSON string cannot be automatically recognized when it is obtained from a webserver or general application handler (. ashx) program, and is interpreted as a string type. In fact, it is not difficult to solve this problem, only need to overload a method, the following part of the code posted: the red part of the need to pay attention.
Copy Code code as follows:
$ ("#txt"). AutoComplete ("/asmx/executeplan.ashx", {
Extraparams:{hosid:hosid,profid:profid},
minchars:0,
max:700,
Mustmatch:true,
Autofill:true,
Selectfirst:true,
scrollheight:220,
width:640,
Scroll:true,
Parse:function (data) {
var obj=eval ("(" +data+ ")");
var row = [];
for (var i = 0; i<obj.length; i++) {
Row[i] = {Data:obj[i],//json
Value:obj[i].instname,//value in list
Result:obj[i].instname}; Displayed in the Drop-down list.
}
if (obj.length = 1)
{
$ ("#hfInstID"). Val (Obj[0].executeid);
$ ("#Button1"). Click ();
}
return row;
} ,
Formatitem:function (row, I, total) {
},
Formatmatch:function (row, I, max) {
},
Formatresult:function (row, I, max) {
}
});
This problem can be solved, but there is a new problem, that is, Formatitem and formatmatch two events are ineffective, temporarily do not know how to solve. But if you want to do something to fill in the results, that is, call this method, note that this is the same as the previous $ ("#txt"). AutoComplete separately, write in the top of the binding method of the bottom of the good.
$ ("#txt"). Result (function (event, data, formatted) {
});
The specific parameter meaning may refer to the official development document. At present, I use so many functions, in the future, if you encounter a new replenishment.
Add one point: $ ("#txt"). Flushcache (); The method is used to empty the AutoComplete cache, and sometimes there are cache-left problems after changing the parameters.