Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8559545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:04:31+00:00 2026-06-11T16:04:31+00:00

I have this code, $(function() { //var asd = ‘<?php $regions_list_full; ?>’; var projects

  • 0

I have this code,

$(function() {
    //var asd = '<?php $regions_list_full; ?>';
    var projects = [
        {
            value: "jquery",
            label: "jQuery",
            desc: "the write less, do more, JavaScript library",
            //icon: "jquery_32x32.png"
        },
        {
            value: "jquery-ui",
            label: "jQuery UI",
            desc: "the official user interface library for jQuery",
            //icon: "jqueryui_32x32.png"
        },
        {
            value: "sizzlejs",
            label: "Sizzle JS",
            desc: "a pure-JavaScript CSS selector engine",
            //icon: "sizzlejs_32x32.png"
        }
    ];


    $( "#find" ).autocomplete({
        minLength: 0,
        source: projects,
        focus: function( event, ui ) {
            $( "#find" ).val( ui.item.label );
            return false;
        },
        select: function( event, ui ) {
            $( "#find" ).val( ui.item.label );
            //$( ".module h1" ).val( ui.item.value );
            $(":header.title").html(ui.item.value);
            //$( "#project-description" ).html( ui.item.desc );
            //$( "#project-icon" ).attr( "src", "images/" + ui.item.icon );

            return false;
        }
    })
    .data( "autocomplete" )._renderItem = function( ul, item ) {
        return $( "<li></li>" )
            .data( "item.autocomplete", item )
            .append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
            .appendTo( ul );
    };
    });

actually this is from the autocomplete of jQueryUI, and I have an array of values which are fetched from the database. What I want is to replace my values into the var projects =[{value:asd}] such that my suggestions of the autocomplete will be the data from the database. How would I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:04:33+00:00Added an answer on June 11, 2026 at 4:04 pm

    You don’t want to use source: projects you probably want to define a function for the source using an AJAX call like this

    $( "#search_address" ).autocomplete({
        source: function( request, response ) {
            $.ajax({
                url: '/path/to/script',
                dataType: 'json',
                data: 'whatever you need here', // i.e. term value
                dataFilter: function (data, type) {
                    // do whatever you need to here to change data into proper autocomplete array format
                    // if JSON data is already in correct format you can just do this.
                    response($parseJSON.(data));
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    // handle error here
                },
                success: function(data) {
                    // maybe check for case of empty data object here (i.e. successful URL request, but no data returned)
                    return data;
                }
            });
        }
    });
    

    Now you typically want to limit the number of results returned by your API (maybe 10 or 20 records at most), as it is likely a bad UI experience to have 1000 items show up in autocomplete. On a good autocomplete the number of results should decrease dramatically after a few letters have been types in. This also make you script perform much better in that you are only processing a handful of returned records. For the same reason, you may also want to use the minLength property of autocomplete to not even bother starting the request until X number of characters are entered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code function getSelectData(id) { jQuery(id).change(function () { var value=''; jQuery(id+ option:selected).each(function
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I have this code in jquery : $(#order_btn).click(function(){ var totalprice = $(.price_amount).text(); $(#totalprice).val(totalprice); });
I have this code in jQuery.. $(document).ready(function(){ var fieldCounter = 0; ... I have
I have this code <html> <include jquery> <script> function crea() { var html =
i have this code: $('#categories').change(function() { var myCars = new Array(Saab, Volvo, BMW); addRowToTable(this.value,
I have this following code $(function () { $.post(fetch_data.php?url=+$('#url').val(), { }, function(response){ var arrValues
I have this code: _trackit: function(){ for(var key in this.items.sublinks){ switch(key){ case 'shoes': for(var
I have this code here: var Person = (function() { var name; var PersonConstructor
I have this code: $('.user_info').click(function(){ var pos = $(this).offset(); rel_value = $(this).attr('rel'); $('#' +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.