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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:14:37+00:00 2026-06-01T20:14:37+00:00

I have created a web service that is basically a json set of values

  • 0

I have created a web service that is basically a json set of values for a set of actions in my app. The idea is that it will return from a MongoDB Collection a set of key/values. So far the return value is somewhat like:

    {"d":"[{\"label\":\"Add A Customer\",\"value\":\"\/EdCustomer\/\"},{\"label\":\"View Suppliers\",\"value\":\"\/Suppliers\/\"},{\"label\":\"Add A Customer\",\"value\":\"\/EdCustomer\/\"}]"}

I have the following Javascript/JQuery to make this work with the Autocomplete that is part of JQuery UI:

   var commands;
   var commandstest = [
  {
     value: "test1",
     label: "test1"
  },
  {
    value: "test2",
    label: "test2"
  }
 ];
  $(document).ready(function () {
     //The search button
    $("#btnCmdSearch")
     .button()
     .click(function () {
        alert("You searched for " + txtSearch.value);
    });

$.ajax({
  url: "http://localhost:50305/SearchCommands.svc/GetCommands",
  dataFilter: function (data) {
    var msg = eval('(' + data + ')');

    if (msg.hasOwnProperty('d'))
      return msg.d;
    else
      return msg;
  },
  success: function (data) {
     commands = data;
  }
});

//The search Box AutoComplete...
$("#txtSearch").autocomplete({
  source:commands,
  minLength: 2,
});

});

What is interesting is that when i use the commandstest in the source of the autocomplete method it works as expected. If i use commands (the json array) then nothing happens. I looked in chrome and i get the error :

    Uncaught TypeError: Property 'source' of object #<Object> is not a function

If I change the declaration of var commands to:

   var commands = new Array();

Then this error message doesn’t appear but still nothing happens with the autocomplete. What on earth am I doing wrong?

  • 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-01T20:14:38+00:00Added an answer on June 1, 2026 at 8:14 pm

    i think source needs to be a call back function which returns a response

    i.e.

    $("#txtSearch").autocomplete({
      source: function(request, response){ response(commands); },
      minLength: 2,
    });
    

    reply if tats not working then im going to take a closer look at it.

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

Sidebar

Related Questions

I have a JSON response from a web service that I need to be
I have a web service that I created in C# and a test harness
I have created a timeclock application in C# that connects to a web service
I have created an Ajax enabled WCF web service that contains this simple method:
I have created a JAX-WS client within eclipse that will communicate with a web
I have created Web-Service in asp.net with c# . Now i want to pass
I have created an web service I need to publish this service. I need
I have created a web service which has a couple of methods developed using
I have created a web service via WCF. Then I exposed it as a
I have created a web service which is saving some data into to db.

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.