N00Blog


JQuery
July 14, 2008, 6:15 am
Filed under: Web Applications | Tags: , , , , , ,

JQuery is a Javascript library which aims to simplify the use of javascript within html and make it more efficient. it is able to perform actions with one line of code which would normally take numerous lines of javascript.

Minifying is the automated process of minimizing the number of characters used in each action to the smallest amount, then used by JQuery. The resulting code will have the same functionality as the previous code, but load and run faster, and is often easier to understand.

JQuery has an inbuilt function :

$(document).ready(function(){ // Your code here });

which allows scripts to be run after the page has been loaded. In regular javascript, this type of action would require use of the onload attribute, often within the body tag. While this would require multiple lines of code, the built in ready function needs only one.

another useful part of JQuery is its chainability, meaning that actions previously spanning lines of code may be seperated by full stops in order to have each action follow on from one another.eg:

$(“p.surprise”).addClass(“ohMy”).show(“Slow”);

first finds any paragraphs named “surprise”, then adds a class to these called “ohMy”, and finally displays the content slowly

 $("a").click(function(event){   event.preventDefault();   $(this).hide("slow"); });

with this code, as far as i can tell, it works when the specified link is clicked on. It stops the link performing the default action (opening the location), and instead hide the link slowly.



AJAX
July 7, 2008, 11:16 pm
Filed under: Web Applications | Tags: , , , , , ,

AJAX, or Asynchronous Javascript and XML is a collection of standardized web tools which can be used for manipulating web applications and webpages. While it has existed for over a decade, the name “AJAX” only came into use in 2005. The fact that it operates “Asynchronously” means that while traditional webpages would be updated completely upon user input, AJAX pages are able to request and manipulate data in specific areas of the page, while retaining much of the page.

To do this, AJAX uses the XMLHttpRequest object, which queries the specified server for the information to be updated. Internet Explorer and Firefox both handle these objects differently; while IE requires it to be called as an ActiveX object, FF allows the XMLHttpRequest to be an object in its own right.

To check the progress of these requests, and perform actions based on it, there exists the property “readyState”. This can have a value from 0 to 4, corresponding to the states from initialized to complete. Using this property, functions can be set to run, for example, when the process is at state 2, or when it has been sent.

It can be seen that the XMLHttpRequest is a powerful tool for web development, allowing for faster loading, more efficient and powerful web pages and applications.