Problem 1: When a json string is obtained from a webserver or a general application processing program (. ashx), it cannot be automatically identified and is interpreted as a string type. In fact, it is not very difficult to solve this problem. You only need to reload a method. Below we will post some code: Pay attention to the red part.
Copy codeThe Code is 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 the list
Result: obj [I]. instName}; // It is displayed in the drop-down list.
}
If (obj. length = 1)
{
// $ ("# HfInstID" 2.16.val(obj1_02.16.exe cuteID );
// $ ("# Button1"). click ();
}
Return row;
},
FormatItem: function (row, I, total ){
},
FormatMatch: function (row, I, max ){
},
FormatResult: function (row, I, max ){
}
});
In this way, the problem can be solved, but a new problem occurs, that is, both the formatItem and formatMatch events are invalid, and I do not know how to solve them yet. However, if you want to perform some operations when entering the results, you can call this method. Note that this is the same as the previous $ ("# txt "). autocomplete is written separately and written at the bottom of the binding method above.
$ ("# Txt"). result (function (event, data, formatted ){
});
For specific parameter meanings, refer to the official development documentation. Currently, I have used so many features that I will try again later.
Add: $ ("# txt"). flushCache (); the method is used to clear the autocomplete cache. Sometimes there will be cache issues after the parameter is changed.