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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:26:34+00:00 2026-05-20T03:26:34+00:00

I have a basic question on JSON Jquery, and it seams I am sort

  • 0

I have a basic question on JSON Jquery, and it seams I am sort of stuck some at a point of extracting array objects. My Code below is in javascript, and I just wanted some clarifications as what I might be doing wrong here.

<?php  
$nor = $_SESSION["north"];
$sou =  $_SESSION["south"];
$eas =  $_SESSION["east"];
$wes = $_SESSION["west"];

session_destroy();

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">  
<html>  
  <head>  
    <title>jQuery JSON test</title>  
  </head>  

  <body>  


<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.js"></script>  
    <script type="text/javascript">  
    var north = "<?php echo $nor ?>";
        var south = "<?php echo $sou ?>"; 
        var east = "<?php echo $eas ?>";
        var west = "<?php echo $wes ?>";

        document.write(north,south,east,west);


    $(document).ready(function(){

        alert("begin loop");
        $.getJSON('http://api.geonames.org/earthquakesJSON?north=' + north + ' &south=' + south + '&east=' + east + '&west=' + west +'&callback=?',
        function(data){
            alert(data.earthquakes);
    });
})

    </script>  

  </body>  
</html>  

So when I use alert(data.earthquakes); I get undefined operation, which is fine but I know here I am getting a response back. However the architecture of the JSON is as following:

{"earthquakes": [
     {"eqid":"2007hear","magnitude":8.4,"lng":101.3815,"src":"us","datetime":"2007-09-12 09:10:26","depth":30,"lat":-4.5172},
     {"eqid":"2007aqbk","magnitude":8,"lng":156.9567,"src":"us","datetime":"2007-04-01 18:39:56","depth":10,"lat":-8.4528},
     {"eqid":"2007hec6","magnitude":7.8,"lng":100.9638,"src":"us","datetime":"2007-09-12 21:49:01","depth":10,"lat":-2.5265}
]}

So I have tried different ways of extracting information such as alert(data.earthquakes[1].eqid); and alert(data.earthquakes.eqid[1]);, however I am not getting the dedicated array as wanted.

Could someone direct me as

  1. how to get the desired architecture result appropriately and
  2. if I want to use array and for loop to extract all the elements into local array,

how to do that?

  • 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-20T03:26:35+00:00Added an answer on May 20, 2026 at 3:26 am

    If your JSON object is defined as follows:

    var jsonData = {"earthquakes": [
             {"eqid":"2007hear","magnitude":8.4,"lng":101.3815,"src":"us","datetime":"2007-09-12 09:10:26","depth":30,"lat":-4.5172},
             {"eqid":"2007aqbk","magnitude":8,"lng":156.9567,"src":"us","datetime":"2007-04-01 18:39:56","depth":10,"lat":-8.4528},
             {"eqid":"2007hec6","magnitude":7.8,"lng":100.9638,"src":"us","datetime":"2007-09-12 21:49:01","depth":10,"lat":-2.5265}
        ]};
    

    Try this:

    var myData = eval('(' + jsonData + ')');
    var firstElement = myData.earthquakes[0];
    

    This is a good point of reference: http://www.json.org/js.html

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

Sidebar

Related Questions

No related questions found

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.