Ajax tutorial

Ajax tutorial

This Ajax tutorial is a term for a type of programming made popular in 2005 by goggle.com and other big web developers. It loosely stands for Asynchronous JavaScript and xml, which sounds like a whole bunch of techno lingo to your average person. In plain words, in this tutorial we show that Ajax can be thought of as JavaScript on drugs.

Ajax- JavaScript on drugs

When JavaScript first came out, people loved all the cool things you could do with the web browser to make it a more user-friendly experience. You could do many things from validation, quirky popup messages; make cool web tools and much more. However, JavaScript had no way of sending information back and fourth between the web browser and the web server.

If you wanted to get any information from a database on the server, or to send user information to a server script like php, you had to make an html from to Get or Post data to the web server. The user would then have to click submit, and then wait for the server to respond, then a new page would load the results. I’m sure everyone has gotten slightly peeved for having to wait for especially slow websites.

Ajax attempts to remedy this problem by letting JavaScript communicate directly with the server, using a special JavaScript object such as xmlhttprequest. With this object, you could have JavaScript get information from the server without having to load a complete new page.


( Read more )

Understanding scope in JavaScript object oriented programming

When you think of the keyword this you probably assume it refers to the current instance of the class. This is true for most object oriented programming like C# and Java.
For example I could use the this keyword in C# like this:

class Cat {
string _name;
public Cat(string name) {
this._name = name;
}
}

In the above example you see this illustrated. In C# and Java, this always refers to the class instance.

So, knowing this you would probably assume the same would be true of object oriented programming in JavaScript and it's this keyword. This is, however, not the case. Like a lot of things about writing object oriented code in JavaScript, this behaves differently in some situations. this does not always refer to the class instance depending on how you use it.

function Cat(name) {
this.Name = name;
}

In the above object oriented programming example it works just like our C# example but look at a situation where things can go wrong if you are unaware of some rules.

( Read more )

The World's Most Misunderstood Programming Language

JavaScript, aka Mocha, aka LiveScript, aka JScript, aka ECMAScript, is one of the world's most popular programming languages. Virtually every personal computer in the world has at least one JavaScript interpreter installed on it and in active use. JavaScript's popularity is due entirely to its role as the scripting language of the WWW.

Despite its popularity, few know that JavaScript is a very nice dynamic object-oriented general-purpose programming language. How can this be a secret? Why is this language so misunderstood?

The Name
The Java- prefix suggests that JavaScript is somehow related to Java, that it is a subset or less capable version of Java. It seems that the name was intentionally selected to create confusion, and from confusion comes misunderstanding. JavaScript is not interpreted Java. Java is interpreted Java. JavaScript is a different language.

JavaScript has a syntactic similarity to Java, much as Java has to C. But it is no more a subset of Java than Java is a subset of C. It is better than Java in the applications that Java (fka Oak) was originally intended for.

JavaScript was not developed at Sun Microsystems, the home of Java. JavaScript was developed at Netscape. It was originally called LiveScript, but that name wasn't confusing enough.

The -Script suffix suggests that it is not a real programming language, that a scripting language is less than a programming language. But it is really a matter of specialization. Compared to C, JavaScript trades performance for expressive power and dynamism.


( Read more )