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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:20:07+00:00 2026-05-30T02:20:07+00:00

This is the view from my browser: { data: { request: [{ query: Lat

  • 0

This is the view from my browser:

{
    "data": {
        "request": [{
            "query": "Lat 41.85 and Lon -87.65",
            "type": "LatLon"
        }],
        "time_zone": [{
            "localtime": "2012-02-14 16:05",
            "utcOffset": "-6.0"
        }]
    }
}

Now, I am using this code to parse it:

function getTimeZone(latlong) {
    jQuery(document).ready(function ($) {
        $.ajax({
            url: "http://www.worldweatheronline.com/feed/tz.ashx?key=[removed]&q=" + latlong + "&format=json",
            dataType: "jsonp",
            success: function (parsed_json) {
                console.log(parsed_json.time_zone.utcOffset);
                return parsed_json.time_zone.utcOffset;
            },
            error: function (parsed_json) {
                //console.log("Error: " + parsed_json);
            }
        });
    });
}

Every time I run the code, I am getting this error:

Uncaught TypeError: Cannot read property 'utcOffset' of undefined

Any assistance would be greatly appreciated.

View of the data being displayed to the console (only copied the part I’m interested in):

Result:
  Object
    data: Object
      request: Array[1]
        time_zone: Array[1]
          0: Object
            localtime: "2012-02-14 16:46"
            utcOffset: "-6.0"
  • 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-30T02:20:08+00:00Added an answer on May 30, 2026 at 2:20 am

    Actually, there are two issues:

    1) to access the content, you need:

    parsed_json.data.time_zone[0].utcOffset;

    2) This is a bit more complex – you are using an asynchronous ajax callback – success() is not being called before your program finishes sending the ajax request and returns, and it does not return its results to the parent method.

    The basically can’t do it the way you want to, unless you use a synchronous fetch (a bad idea, since it’ll lock up your browser until the response arrives).

    Instead, take a callback parameter, which will be a function, as a parameter to your function, and call that with the result once it arrives:

    i.e.

    function getTimeZone(latlong, callback) {
        jQuery(document).ready(function ($) {
            $.ajax({
                url: "http://www.worldweatheronline.com/feed/tz.ashx?key=[removed]&q=" + latlong + "&format=json",
                dataType: "jsonp",
                success: function (parsed_json) {
                    console.log(parsed_json.time_zone.utcOffset);
                    callback(latlong, parsed_json.data.time_zone[0].utcOffset);
                },
                error: function (parsed_json) {
                    //console.log("Error: " + parsed_json);
                }
            });
        });
    }
    

    Then to use it:

    getTimeZone(myLatLong, function(latLong, utcOffset) {
       // ... do something with utcOffset here ...
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my query, CREATE VIEW employee_vu AS( SELECT employee_id,last_name employee,department_id FROM employees); I
In this code I am loading a View Controller (and associated View) from a
This is very basic question from programming point of view but as I am
I am asking this question from an educational/hacking point of view, (I wouldn't really
I am using this to determine which view to go to next, from the
Today I run this select 'exec sp_refreshview N''['+table_schema+'].['+table_name+']''' from information_schema.tables where table_type = 'view'
Is it possible to re-write (Apache Mod-Rewrite) a URL from this: http://www.example.com/view.php?t=h5k6 to this
I'm trying to make a custom view in Django admin. I'm reading from this
I need ability to display content in Hex View, like this from WinHex Offset
My Django app displays data from a database. This data changes without user intervention,

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.