About jquery+php query MySQL implementation autocomplete feature, write this tutorial, because most of the applications you've seen about auto-completion just give you a program source package and then tell you how to use it instead of telling you how it works and why. Knowing this will allow you to further customize the plugin to your needs (I have written a lot of articles about other applications in my blog).
OK, let's start now.
JavaScript code :
Copy to ClipboardWhat to refer to: [www.bkjia.com]
JS's explanation:
Well, from the code above, we need to connect to a file called rpc.php, which handles all operations.
The lookup function uses the word from the text input box and then uses the Ajax method post in jquery to pass it to rpc.php.
If the input character ' inputstring ' is ' 0 ' (Zero, that is, it is not entered in the search box), the suggestion box is hidden, which is also very human, you think, if you do not enter anything in the search box, you do not expect to appear a suggestion prompt box.
If there is content in the input box, we get the ' inputstring ' and pass it to the rpc.php page, and then the jquery. Post () function is used, as follows:
. Post (URL, [data], [callback])
The ' callback ' section can be associated with a function, which is interesting only when the data is loaded successfully (this is a free translation, not read the original:<).
If the returned data is not empty (that is, there is something to display), then a search prompt is displayed and the returned data is used instead of the HTML code.
It's so easy!
- Total 4 Pages:
- Previous page
- 1
- 2
- 3
- 4
- Next page
http://www.bkjia.com/PHPjc/364623.html www.bkjia.com true http://www.bkjia.com/PHPjc/364623.html techarticle about jquery+php query MySQL implementation auto-completion function, write this tutorial, because most of the auto-completed applications have just given you a program source package, and then Sue ...