Reputation: 39
JS = {
xml : function() {
if(window.XMLHttpRequest) {
this.http = new window.XMLHttpRequest();
}
},
xml.prototype.ajax : function() {
alert(this.http);
}
}
returns Uncaught SyntaxError: Unexpected token .
Upvotes: 0
Views: 22
Reputation: 79
This isn't a closure its an object declaration. You can't access the xml property inside the JS object. You would have to do this.
JS = {
xml : function() {
if(window.XMLHttpRequest) {
this.http = new window.XMLHttpRequest();
}
},
}
JS.xml.prototype.ajax = function() {
alert(this.http);
}
Upvotes: 1