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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:47:21+00:00 2026-05-23T10:47:21+00:00

I want to develop an autocomplete input. I have my controller action for this:

  • 0

I want to develop an autocomplete input.

I have my controller action for this:

def autocomplete_airports
    render :json => WebService.get_airports(params[:airports_input])
end

get_airports returns entries separated by commas (,):

def self.get_airports(code)
    #SOAP Action
    begin response = @@client_airports_codes.request :tem, 'airports' do
        soap.body =
          {
          "tem:prefixText" => code,
          "tem:count" => @@airport_response_count
        }
      end
    rescue Savon::SOAP::Fault => fault
      puts fault.to_s
    end
    #preparing response
    json = ""
    response.to_hash[:airports_response][:airports_result][:string].each{
      |key| json = json + key.to_s + ","
    }
    return json
  end

In my view:

<form id="airport_form" class="center" action="">
  <label for="airports_input">Airport/City</label>
  <br />
  <input type="text" name="airports_input" id="airports_input" />
</form>

And my JavaScript:

$('#airports_input').autocomplete('/WebServices/autocomplete_airports');

But, it doesn’t work.

what should I do?

Thank you!

  • 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-23T10:47:22+00:00Added an answer on May 23, 2026 at 10:47 am

    I think you need to return an array of key-value pairs to make this work. Look @ my answer to to another recent question.

    I’ll add the relevant model code not contained in that answer here (note: Rails 3.0):

    def self.search(search = nil)
      if search
        where('name LIKE ?', "%#{search}%") | tagged_with("%#{search}%")
      else
        scoped
      end
    end
    
    def self.autocomplete(search)
      results = search(search)
      results.map! { |result| {:value => result.name} }
    end
    

    Hope this helps.

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

Sidebar

Related Questions

I want to develop a simple iPhone application. However, I do not have the
I want to develop an app with the Spotify API. I have downloaded the
i want to develop one desktop application using c# sql lite, this application i
I want develop an application on windows mobile. In this app, i need to
I want to develop a gesture recognition. I'm considering using the Kinect to have
I want to develop a test project for inline editing using jQuery. In this
I want to develop a windows application. If I use native C++ and MFC
I want to develop Java apps, real quick, what IDE should I choose?
I want to develop simple Serverless LAN Chat program just for fun. How can
I want to develop a mobile web application using asp.net 3.5 that can be

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.