Before you write a single line of JavaScript, think about how you can objectify it. In JavaScript you can wrap your code in object like statements so that name space does not get clobbered by other code.
Notice how the functions are set as variables and calls to them are invoked as if it was a real object language.
function myobject() { var MyVar = 0; this.PageSetup = function() { var _this = this; } this.SendCommand = function(Url) { var GetHttp = new XMLHttpRequest(); GetHttp.open("GET", Url, true); GetHttp.send(null); } }; // end of object var myobject1 = new myobject(); myobject1.SendCommand("mydomain.url/doStuff");
No comments:
Post a Comment