I have a JS object that look something like this.
function Product() {
this.prop1 = 1;
this.prop2 = 2;
}
function Work(values) {
this.prodID = 0;
this.anotherProp = 1;
this.updateProductID = function(newProdID) {
var sourceURL = "the URL here";
alert("ID is: " + this.product.prodID); //displays 0
$.getJSON(sourceURL, function(data) {
//I want to update the property like this
this.product.prodID = data.Products.ProductID;
})
};
What I am trying to do is make a json call and populate the product.ProdID property of the instance of the Work Object but I always get this.product is undefined.