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

The Archive Base Latest Questions

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

I have an issue and this is not something that I have ever used

  • 0

I have an issue and this is not something that I have ever used before.

This is a snippet of the code.

//Defined at top of file
var ships_array = [];

//Function later on

    function refreshJSON(){
    $.getJSON("scripts/getJSON.php", function(json){

      if(json){
        $.each(shiplist,function(i,item){
            $.each(item,function(j,subitem){
                var mmsi = subitem['mmsi'];
                ships_array[mmsi].lat = subitem['lat'];
                ships_array[mmsi].lon = subitem['lon']; 

            });
        });
     } 

    });

    }

The error I am getting is

ships_array[mmsi] is undefined [Break
On This Error] ships_array[mmsi].lat =
subitem[‘lat’];

Is this the right way to use an associative array? I have seen an example similar to this but I am going wrong somewhere! At the end of it I want an array of Google Maps markers!

  • 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-20T14:31:27+00:00Added an answer on May 20, 2026 at 2:31 pm

    you just need to initialize the value at the hash key first

    var mmsi = subitem['mmsi'];
    ships_array[mmsi] = ships_array[mmsi] || {};
    ships_array[mmsi].lat = subitem['lat'];
    ships_array[mmsi].lon = subitem['lon'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This would be my issue I have a drop down that's not displaying fully.
I do not currently have this issue , but you never know, and thought
I have seen a few posts regarding this issue but not one specific to
I know this issue has been touched on here but I have not found
This is not an issue with a few tables, but when I have a
After repeated searching I have not found an elegant solution to this issue: how
can you please help me with this issue the String class does not have
I know there are tons of threads regarding this issue but I have not
I have this issue with ComboBox that uses IEnumerable<Brush> as ItemsSource; the problem lies
Im having issues getting this to work, maybe its not even possible? I have

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.