I have multiple objects in a hierarchy which have common properties and methods inherited from the superclass, and object-specific properties and methods in the subclasses. I'm still new to OOP javascript, so there is probably a much better approach to this. I'm using jQuery for the AJAX, but not sure if that makes any difference.
function Obj(input) {
this.in = input;
this.out = {
content: this.in,
category: {},
owner: utils.getValidUser(),
state: 0,
meta: {}
};
this.process = function() {
console.log("No Process Defined");
}
}
function MovieObj(input) {
this.inheritFrom = Obj;
this.inheritFrom();
this.out.type = "movie";
}
function ActionMovie(input) {
this.inheritFrom = MovieObj;
this.inheritFrom();
this.out.genre = "action";
this.process = function() {
console.log("movie search");
$.getJSON("/api/search/"+ escape(this.out.content),
function(data) {
/*
I want to modify the object properties according to
what comes back from the ajax call.
*/
});
}
}