JQuery.get() and Javascript objects
Hi,
I am complitely new to Javascript and JQuery. And I think that I run into problem that could be related to scope of javascript variables.
I am trying to build CSSParser object with _strCSS member variable and method that uses .get() to populate _strCSS with content of the file.
Here is my example:
function CSSParser() {
this._strCSS = '';
this.parseCSSFile = parseCSSFile;
}
function parseCSSFile(cssFile) {
$.get(cssFile, function(str){this._strCSS = str;});
alert(this._strCSS);
}
alert(this._strCSS) will not output anything since this._strCSS is not defined. However if I use alert(this._strCSS) inside get callback function I will get proper output.