Search Cerebrotech Blog

Saturday, 6 June 2015

Workings of the Application Layer - The Power of jQuery

jQuery is a cross browser JavaScript library developed to aid the client side scripting of HTML (Hyper Text Mark up Language). The Library is widely used today to handle events, validate forms, to create DOM elements, to create animations and develop Ajax applications during web development. jQuery was created by an American software developer known as John Resig. For most programmers who use javascript language, there has been the issue of cross browser compatibility. There was always the error associated with having a javascript code as more internet browser apps came on stream. The most notorious of these errors was the fact that the HTML page loads simultaneously with the javascript code and as such, if the page loads after the javascript, there are errors associated with the application layer.

jQuery library was introduced to solve all these problems and as an open source it is been improved upon by a team of developers. A look at a jQuery code, the first line of code after importing the library is;
 $.(Document).ready(function(){
      //All codes fall within this area
});

The "$" sign is used by jQuery as a selection tool, therefore, in trying to explain the above code, it simply means, select the document (by that, we mean the current document that is open) and when its ready, perform a series of functions which will be with the area "//All codes fall within this area". By this first act, the JavaScript code loads only after the HTML page finishes loading.

CSS (Cascading Style Sheet) is a necessary language for working with jQuery, as it works in the Presentation layer to improve the appearance of the web page(s). I once put on my Facebook update:

"I have come to the realization that art (self expression) is the best field of human endeavour. Science simply presents us with tools, techniques and processes to aid the the expression of one's self... Nobody cares about how for instance a MacAir system works, all you see is this sleek, beautiful machine..."

I think people are impressed by what they see and not what's going on in the background, so CSS help improve the looks combining with other scripting and markup languages.

One of the uses of jQuery is in form validations. The form elements which includes the input elements with attribute types text, button or radio are all given class and ID names. jQuery uses the $.("#ID-Name") to select an element with the corresponding ID name and $.(".Class-Name") to select an element with a class name. Once the input element is selected, the value can be extracted and the data manipulated. After processing the data, it is sent to the server-side scripting language (PHP) as seen in Fig.1 using Ajax - A group of inter-related web development capabilities which includes HTML, CSS, DOM, XML, XSLT, XMLHttpRequest and JavaScript.

Fig. 1 - PAD Architecture

PHP for me is a server side scripting language with large Object Oriented Programming features. it receives the data posted asynchronously via Ajax, performs further data and object manipulations and inserts into the database. All these happens in the background without the page refreshing. Amazing stuff! For upcoming web developers, I'd advice you to be grounded in HTML, CSS, and JavaScript before delving into the server-side scripting languages and Data layer systems.

Finally, jQuery is used in creating powerful web animations. what comes to mind? ActionScript (Flash) is under threat? I believe so. But as jQuery stands, developers keep churning out powerful web animations in the form of banners, games etc.

Emeka.Iwuchukwu@cerebrotech-ng.com


No comments:

Post a Comment