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

  • Home
  • SEARCH
  • 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 7560117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:48:55+00:00 2026-05-30T12:48:55+00:00

Im trying to use a Web Service to set an Airport code using Jquery

  • 0

Im trying to use a Web Service to set an Airport code using Jquery UI autocomplete:

The WS is:
http://airportcode.riobard.com – http://airportcode.riobard.com/search?q=dallas&fmt=JSON

I can’t create the autocomplete, here is my javascript code:

<script>
$(function() {
    function log( message ) {
        $( "<div/>" ).text( message ).prependTo( "#log" );
        $( "#log" ).scrollTop( 0 );
    }

    $( "#city" ).autocomplete({
        source: function( request, response ) {
            $.ajax({
                url: "http://airportcode.riobard.com",
                dataType: "jsonp",
                data: {
                    fmt: "JSONP",
                    q: request.term
                },
                success: function( data ) {
                    response( $.map( data.geonames, function( item ) {
                        return {
                            label: item.code + (item.name ? ", " + item.location : "") + ", " + item.location,
                            value: item.code
                        }
                    }));
                }
            });
        },
        minLength: 2,
        select: function( event, ui ) {
            log( ui.item ?
                "Selected: " + ui.item.label :
                "Nothing selected, input was " + this.value);
        },
        open: function() {
            $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
        },
        close: function() {
            $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
        }
    });
});
</script>




 <!-- HTML Code is -->

<div class="demo">

<div class="ui-widget">
    <label for="city">Your city: </label>
    <input id="city" />

</div>

<div class="ui-widget" style="margin-top:2em; font-family:Arial">
    Result:
    <div id="log" style="height: 50px; width: 200px; overflow: auto;" class="ui-widget-content"></div>
</div>

</div><!-- End demo -->
  • 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-30T12:48:56+00:00Added an answer on May 30, 2026 at 12:48 pm

    First off, the data source you’re using does not support JSONP. You can’t just grab an arbitrary JSON data source and tell jQuery it’s JSONP and expect it to work. The server must be configured to take a callback argument that it appends to the response, calling your code when it completes and is injected onto the page.

    You can get around this by using YQL or writing your own server-side code that calls the service.

    Here’s an example using YQL:

    function buildQuery(term) {
        return "select * from json where url = 'http://airportcode.riobard.com/search?fmt=JSON&q=" + encodeURI(term) + "'";
    }
    
    function makeRequest(request, response) {
        $.ajax({
            url: 'http://query.yahooapis.com/v1/public/yql',
            data: {
                q: buildQuery(request.term),
                format: "json"
            },
            dataType: "jsonp",
            success: function(data) {
                var airports = [];
                if (data && data.query && data.query.results && data.query.results.json && data.query.results.json.json) {
                    airports = data.query.results.json.json;
                }
    
                response($.map(airports, function(item) {
                    return {
                        label: item.code + (item.name ? ", " + item.location : "") + ", " + item.location,
                        value: item.code
                    };
                }));
            },
            error: function () {
                response([]);
            }
        });
    }
    
    $(document).ready(function() {
        $("#airport").autocomplete({
            source: makeRequest,
            minLength: 2
        });
    });​
    

    So instead of calling the web service directly, we’ll ask YQL to make the request and return a result. YQL acts as a wrapper, making an otherwise inaccessible web service accessible via JSONP.

    In the success method, we have to go through several properties to finally access the data. After we do that, we can format the results in a way that the autocomplete widget expects (with $.map).

    Example: http://jsfiddle.net/BQxw4/40/

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

Sidebar

Related Questions

We're trying to use Axis2 to call a web service that cannot use HTTP/1.1
I'm trying to use jQuery to get data from an ASP.NET web service (SharePoint
I'm trying to use WCF 4 to set up a RESTful web service. I'd
im trying to use the jQuery UI autocomplete to communitate with a webservice with
I'm trying to use a RESTful web service in Adobe AIR. The service uses
I'm trying to connect to http://cmis.demo.nuxeo.org/nuxeo/atom/cmis/ with NSURLConnection . This demo web service is
I'm trying to use Zend_Soap_Client to communicate with an ASP.net web service. Here's my
I'm trying to set up a web service so that it will download zip
I'm trying to bring back information from a web service and then use that
I'm trying to create a web service client using CXF to consume a WCF

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.