开发者

How I can get my DB values inside the tag of my Jquery UI pligin?

开发者 https://www.devze.com 2023-01-13 16:44 出处:网络
$(function() { var availableTags = [\"ActionScript\", \"AppleScript\", \"Scheme\"]; $(\"#tags\").autocomplete({
    $(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
0

精彩评论

暂无评论...
验证码 换一张
取 消