How I can get my DB values inside the tag of my Jquery UI pligin?
$(function() {
var availableTags = ["ActionScript", "AppleScript", "Scheme"];
$("#tags").autocomplete({
source: availableTags
});
I开发者_如何学C don want the values inside the tags. i have a JS page i need to make a function for connecting my DB to the auto complete plugin. How can i do it suggestions Please.
Thanks in Advance..
You can not connect to a database using only JavaScript and you should never show your database values in JavaScript as everybody can read them.
You have to use a server side script to connect to your database, resolving the autocomplete values and responding them to the autocomplete plugin.
So in gerenal you don't use a local "source" with the suggestions, but a server side script and getting the values through ajax calls:
$("#tags").autocomplete('url_to_server_side_script');
EDIT: So i looks like it is a JSP page. After getting the values wihtin the function, you have to create an output (and use the "reponse" to send it to the client) with each value in a new line looking like this:
ActionScript
AppleScript
Scheme
You can even use HTML to markup the match of the query string (let's asume it was "Sc"):
Action<em>Sc</em>ript
Apple<em>Sc</em>ript
<em>Sc</em>heme
精彩评论