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 6734659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:54:55+00:00 2026-05-26T10:54:55+00:00

How is ti possible that the code below show the array ONLY if the

  • 0

How is ti possible that the code below show the array ONLY if the text is empty… It should show the list during the typing NOT when the text is empty.

STEPS:

  1. Focus on text
  2. type a text, like ‘abc’ (this text returns an array doing the ajax call)
  3. nothing happen
  4. delete ‘abc’ and i see the array correctly.

    $('#titolare').keyup(function(){
      var titolare = $.trim($('#titolare').val());
    
      $.ajax({
        type: "POST",
        url: "page.php",
        data: { titolare: titolare },
        success: function(msg){          
          var obj = jQuery.parseJSON(msg);
    
          if (obj.result){
            var tit   = obj.titolare
              , tit_a = [];            
    
            $.each (tit, function (a) {              
              tit_a[a] = { titolare: tit[a].titolare, cod_fis: tit[a].cod_fis };
            });         
    
                $("#titolare").autocomplete({
              minLength: 0,         
              source: tit_a,
                    focus: function( event, ui ) {             
                        $("#titolare").val(ui.item.titolare);
                        return false;
                    },
                    select: function( event, ui ) {            
                        $("#titolare").val(ui.item.titolare);
                        return false;
                    }
                })
                .data( "autocomplete" )._renderItem = function(ul, item) {          
                    return $( "<li></li>" )
                        .data( "item.autocomplete", item )
                        .append( "<a>" + item.titolare + "<br />("+ item.cod_fis +")</a>")
                        .appendTo( ul );
                };            
    
          }                                             
        }
      });        
    });
    
  • 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-05-26T10:54:55+00:00Added an answer on May 26, 2026 at 10:54 am

    You do not want to use keyUp function. You can give url as the source like this,

    $(document).ready(function(){
        $( "#titolare" ).autocomplete({
                 source: "page.php",                }
                 focus: function( event, ui ) {             
                            $("#titolare").val(ui.item.titolare);
                            return false;
                        },
                        select: function( event, ui ) {            
                            $("#titolare").val(ui.item.titolare);
                            return false;
                        }
        }).data( "autocomplete" )._renderItem = function(ul, item) {          
                        return $( "<li></li>" )
                            .data( "item.autocomplete", item )
                            .append( "<a>" + item.titolare + "<br />("+ item.cod_fis +")</a>")
                            .appendTo( ul );
                    };  
    });
    

    And in your page.php you can return relavant JSON object list.
    http://jqueryui.com/demos/autocomplete/#remote

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

Sidebar

Related Questions

Is it possible to write code in a Flex application that will only be
Should I prepare my code for possible/predicted future changes so that it's easier to
Is it possible that I reserve a asp.net code in db and load it
Is it possible that adding more import statements to your java code could slow
Is it possible to go back and tie work items to code that's already
Is it possible to make a Java program that prints its source code to
Is it possible to include view code in a plugin, such that an app
Okay, of course it is possible, that's no issue. In my code I have
Using the code below, I'm able to show the title and subtitle, and I
I have a loading image that works using the code below. It shows the

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.