Here's what I'm trying to do. I'm trying to pull data from a database and create a new user and continue to check every second for new users and changes in previous users' location (I'm tracking GPS using an Android app). I need to be able to create a new instance each time a new user is added to the DB, but I'm not sure how to do this. I've seen examples like below, but the objects are defined within the program and aren't created 'automatically.'
function cat(name) {
this.name = name;
this.talk = function() {
alert( this.name + " say meeow!" )
}
}
cat1 = new cat("felix")
cat1.talk() //alerts "felix says meeow!"
cat2 = new cat("ginger")
cat2.talk() //alerts "ginger says meeow!"
Let's say I wanted to pull the cat's name from a database and check for new ones each second. I would have a php program that pulls and returns it to this JS program as JSON, but how do I instantiate a new 'cat' by using a function? Any help would be greatly appreciated. Thanks!