I've builded a Chrome extension to do cross-domain ajax requests... Now I'm trying to wrap it into a javascript object oriented framework. Here is the code:
function webpage(url)
{
this.url = url;
this.html = "";
}
webpage.prototype.set_html = function(html)
{
console.log(html); // working
this.html = html; // not working
}
webpage.prototype.get_html = function()
{
request_url(this.url, this.set_html); // call to a working chrome extension
}
var mypage = new webpage("http://www.google.it");
mypage.get_html();
The problem is that the prototype function "set_html" is working great if I call it "the normal way"
mypage.set_html("hello world")
The function "request_url" is working great too
request_url("http://www.google.it",function(data){console.log(data)})
However when I call it like this
mypage.get_html();
The first "console.log" works great and it shows the page_source but the value of this.html won't change... Where I'm wrong?