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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:15:39+00:00 2026-05-20T11:15:39+00:00

I am having trouble on my autocomplete as it is returning only one record

  • 0

I am having trouble on my autocomplete as it is returning only one record whereas the remote webservice is returning 10 items.

Was wondering if you could have a look at my code and see if I’m doing something wrong?

Received data:

{“d”:”[\”02102008633\”,\”02102008794\”,\”02102008980\”,\”02102015321\”,\”02102018743\”,\”02102024602\”,\”02102037454\”,\”02102038366\”,\”02102040774\”,\”02102056369\”]”}

jQuery(txtDestination).autocomplete({
            minLength: 2,
            source: function (request, response) {
                jQuery.ajax({
                    url: "/SearchService.asmx/GetDestinationAutocompleteValue?" + "accountCode=" + accountCode.toString() + "&criteria=" + jQuery(txtDestination).val().toString(),
                    data: "{}",
                    type: "GET",
                    contentType: "application/json; charset=utf-8",
                    success: function (data) {
                        if (data != null && data.hasOwnProperty('d') && eval(data.d) != null) {
                            var result = new Array(eval(data.d));
                            response(jQuery.map(result, function (item, ctr) {
                                return { label: item[ctr], id: item[ctr], value: item[ctr] }
                            }));
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus + " " + errorThrown); }
                });
            }
        });

Thanks a million!

Cheers,
Ann

  • 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-20T11:15:39+00:00Added an answer on May 20, 2026 at 11:15 am

    I think I found it… Take a look at this line:

    var result = new Array(eval(data.d));
    

    Now, since eval(data.d) evaluates to an array already, you’re essentially calling something like this:

    var result = new Array([1, 2, 3]);
    

    Which will actually create an array of length one – the first element of which is an array of length three. This blindsided me, too, until I thought to check it in a JS console (and don’t get me started on the printout not including square brackets…):

    js> ra1 = new Array(1, 2, 3)
    1,2,3
    js> ra2 = new Array([1, 2, 3])
    1,2,3
    js> ra1.length
    3
    js> ra2.length
    1
    

    But the good news is that there’s an easy fix:

    var result = eval(data.d);
    

    Hope this helps!

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

Sidebar

Related Questions

I'm having a little trouble with JQuery autocomplete remote-cache and Zend, it doesn't work
I have implemented Autocomplete and I'm having trouble with the label vs. value in
I'm having trouble getting the autocomplete box in System.Windows.Controls.Input working as I wish. When
I'm having trouble getting Indextank's AutoComplete feature to work in my Rails application. I'm
I've made a javascript autocomplete, but i'm having trouble in its CSS styling. What
I'm having trouble positioning the layout elements. The AutoComplete in my TableLayout and the
I am trying to use Django with jquery UI autocomplete but having trouble sending
Having trouble with an sql statement to retrieve a record between two timestamps. This
Having trouble with some select statements. I have 2 tables. sms_log and sms_messages. sms_log
i'm having some trouble with the autocomplete textview in android. I populate the array

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.