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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:47:41+00:00 2026-05-28T22:47:41+00:00

I’m having an issue where I get an error that says… Uncaught TypeError: Object

  • 0

I’m having an issue where I get an error that says…

“Uncaught TypeError: Object f771b328ab06 has no method ‘addLocation'”

I’m really not sure what’s causing this. The 'f771b328ab06' is a user ID in the error. I can add a new user and prevent users from being duplicated, but when I try to add their location to the list, I get this error.

Does anybody see what’s going wrong? The error occurs in the else statement of the initialize function as well (if the user ID exists, just append the location and do not create a new user). I have some notes in the code, and I’m pretty sure that this is partly due to how I have modified an example provided by another user.

function User(id) {
    this.id = id;

    this.locations = [];

    this.getId = function() {
        return this.id;
    };
    this.addLocation = function(latitude, longitude) {
        this.locations[this.locations.length] = new google.maps.LatLng(latitude, longitude);
        alert("User ID:" );
};
    this.lastLocation = function() {
        return this.locations[this.locations.length - 1];
    };
    this.removeLastLocation = function() {
        return this.locations.pop();
    };
}

function Users() {
    this.users = {};

     //this.generateId = function() { //I have omitted this section since I send
        //return Math.random();       //an ID from the Android app. This is part of
    //};                              //the problem.

    this.createUser = function(id) {
        this.users[id] = new User(id);
        return this.users[id];
    };
    this.getUser = function(id) {
        return this.users[id];
    };
    this.removeUser = function(id) {
        var user = this.getUser(id);
        delete this.users[id];

        return user;
    };
}

var users = new Users();

function initialize() { 
    alert("Start");
    $.ajax({                                      
        url: 'api.php',                                               
        dataType: 'json',                   
        success: function(data){
            var user_id = data[0];
            var latitude = data[1];
            var longitude = data[2];

            if (typeof users.users[user_id] === 'undefined') {
                users.createUser(user_id);
                users.users[user_id] = "1";
                user_id.addLocation(latitude, longitude); // this is where the error occurs
            }           
            else {
                user_id.addLocation(latitude, longitude); //here too
                alert(latitude);
            }
        }   
    })      
}
setInterval(initialize, 1000);

Since I get the ID from the phone and do not need to generate it here (only receive it), I commented out the part that creates the random ID. In doing this, I had to add a parameter to the createUser method within Users() so that I can pass the ID as an argument from Initialize(). See the changes to createUser below:

Before, with the generated ID (the part where the number is generated is in the above code block with comments):

this.createUser = function() {
    var id = this.generateId();
    this.users[id] = new User(id);
    return this.users[id];
};

After, with the ID passed as an argument:

this.createUser = function(id) { 
    this.users[id] = new User(id);
    return this.users[id];
};

If anyone has any suggestions I would really appreciate it. Thanks!

  • 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-28T22:47:41+00:00Added an answer on May 28, 2026 at 10:47 pm

    Here you’re getting user_id by :

    var user_id = data[0];
    

    So it’s a part of the json answer : maybe a string or another dictionnary, this can’t be a user object. You should try to update your code in your success function inside the “if” block by :

    user = users.createUser(user_id);
    
    //The following line is a non sense for me you put an int inside 
    //an internal structure of your class that should contain object
    //users.users[user_id] = "1"; 
    
    user.addLocation(latitude, longitude);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
i got an object with contents of html markup in it, for example: string
I need a function that will clean a strings' special characters. I do NOT

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.