Jquery autocomplete combined asp.net use essentials _javascript tips

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.