I have written two objects. One is called List and another is called Car.
function Car()
{
  this.make="";
  this.year="";
}
function List()
{
  this.cars = [];
}
And I have another function, which is a method of object List to read in XML file's information, and store them in the car array inside List object:
List.prototype.readXML = function()
{
  var i = 0;
  $.get('mydata.xml', function(xml){
    $(xml).find("item").each(function(){
      //Bug Point!!!
      this.cars.push(new Car()); //Push a Car object into array
      this.cars[i].ID = ($(this).attr("ID"));
     }); 
   });
 }
However this won't work. Everytime the debug gives me that cars is not defined... I tried using var instead of this to define cars. And tried to remove this.cars.push instead of cars.push. But still it says the cars is not defined.
I assume that I may get something wrong with the variable scope in this problem. Could any one can teach me how to do it?
Thank you!
 
     
     
     
     
    