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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:47:12+00:00 2026-06-15T23:47:12+00:00

I am trying to parse this JSON string: { RESULTS: [ { name: Thessaloniki

  • 0

I am trying to parse this JSON string:

{ "RESULTS": [ { "name": "Thessaloniki GR", "type": "Sailing", "l": "/sailing-weather/beach:Porto%20Carras%20Marina 45904" }, { "name": "Thessaloniki, Greece", "type": "city", "c": "GR", "zmw": "00000.1.16622", "tz": "Europe/Athens", "tzs": "EET", "l": "/q/zmw:00000.1.16622" } ] }

which is retrieved from here

This is my snippet:

$(document).ready(function () {

  $("#w11").autocomplete({
        source: function (a, b) {
            $.ajax({
                url: "http://autocomplete.wunderground.com/aq",
                dataType: "jsonp",
                data: {
                    format: "jsonp",
                    query: a.term
                },
                success: function (a) {
                    for (i in data.RESULTS) {
                        console.log(data.RESULTS);
                    }
                }
            })
        }
    });


});​

Which gives me an error Uncaught SyntaxError: Unexpected token : on the first line which is { "RESULTS": [

How can I parse the JSON Results?

  • 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-15T23:47:13+00:00Added an answer on June 15, 2026 at 11:47 pm

    You’ve told jQuery to expect JSON-P, not JSON:

    dataType: "jsonp"
    

    …but the result is JSON. JSON-P and JSON are fundamentally different things. Here’s an example JSON response:

    {"foo": 42}
    

    Here’s what a JSON-P response might look like:

    callback({"foo": 42});
    

    or

    callback({foo: 42});
    

    If http://autocomplete.wunderground.com/a is not on the same origin as the document your code is running in, you won’t be able to retrieve JSON from it via ajax because of the Same Origin Policy (unless the server in question supports CORS, allows your origin for the request, and the browser the user has also supports CORS). Which I suspect is why you tried to use JSON-P, which works cross-origin. The thing is, though, that the server has to support JSON-P as well. Despite the format=jsonp in the URL, the server is not responding with JSON-P, but with JSON.

    In the comments, you linked to their docs for that API, which show that they do support JSON-P for it, just using a non-standard argument name in the URL (cb instead of the much more common callback).

    So this should work (I’ve also fixed the issues with the code I mentioned in my comment on the question):

    $.ajax({
        url:      "http://autocomplete.wunderground.com/aq",
        dataType: "jsonp",
        jsonp:    "cb",     // <================= New bit is here
        data:     {
            format: "json", // <=== "json" not "jsonp" according to the docs, but I think the "cb" argument overrides it anyway
            query:  a.term
        },
        success:  function (data) { // <=== `data`, not `a`
            var i;
            for (i in data.RESULTS) {
                console.log(data.RESULTS[i]); // <=== Use [i] here
            }
        }
    }); // <=== Semicolon was missing
    

    And in fact it does work: Live Example | Source

    The jsonp argument tells jQuery what URL parameter to use to define the name of the JSON-P callback. The default is the standard callback but that API uses a non-standard argument.

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

Sidebar

Related Questions

I'm trying to parse this XML string: <?xml version=1.0 encoding=UTF-8 standalone=no?> <response type=success> <lots>
I'm trying to parse a JSON string using the json library. This code works
I'm trying to parse this JSOn with multiple entries of node tag: { nodes:
I'm trying to parse apart a string like this with javascript: var mystr =
I am trying to parse a string which in JSON format only that keys
First: this is my first time using GSON. Trying to parse some JSON, I
I am trying to create a JSONMessage class that can parse a json string
I am trying to parse google's API response json formatted string into datatable. I
I am trying to parse a json string straight into a managed object. The
I am trying to parse this string .... but due to message_of_the_day key ,

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.