Wednesday, August 29, 2018

AJAX - Quick Guide

What is AJAX?

AJAX stands for Asynchronous JavaScript and XML. AJAX is a new technique for creating better, faster, and more interactive web applications with the help of XML, HTML, CSS, and Java Script.

AJAX - Useful Resources

The following resources contain additional information on AJAX. Please use them to get more in-depth knowledge on this topic.

Useful Links on AJAX

AJAX - Current Issues

AJAX is growing very fast and that is the reason that it contains many issues with it. We hope with the passes of time, they will be resolved and AJAX will become ideal for web applications. We are listing down a few issues that AJAX currently suffers from.
Complexity is increased
  • Server-side developers will need to understand that presentation logic will be required in the HTML client pages as well as in the server-side logic.
  • Page developers must have JavaScript technology skills.

AJAX - Security

AJAX Security: Server Side

  • AJAX-based Web applications use the same server-side security schemes of regular Web applications.
  • You specify authentication, authorization, and data protection requirements in your web.xml file (declarative) or in your program (programmatic).
  • AJAX-based Web applications are subject to the same security threats as regular Web applications.

AJAX Security: Client Side

  • JavaScript code is visible to a user/hacker. Hacker can use JavaScript code for inferring server-side weaknesses.
  • JavaScript code is downloaded from the server and executed ("eval") at the client and can compromise the client by mal-intended code.
  • Downloaded JavaScript code is constrained by the sand-box security model and can be relaxed for signed JavaScript.

AJAX - Database Operations

To clearly illustrate how easy it is to access information from a database using AJAX, we are going to build MySQL queries on the fly and display the results on "ajax.html". But before we proceed, let us do the ground work. Create a table using the following command.
NOTE − We are assuming you have sufficient privilege to perform the following MySQL operations.
CREATE TABLE 'ajax_example' (
   'name' varchar(50) NOT NULL,
   'age' int(11) NOT NULL,
   'sex' varchar(1) NOT NULL,
   'wpm' int(11) NOT NULL,
   PRIMARY KEY  ('name')
) 

AJAX - XMLHttpRequest

The XMLHttpRequest object is the key to AJAX. It has been available ever since Internet Explorer 5.5 was released in July 2000, but was not fully discovered until AJAX and Web 2.0 in 2005 became popular.
XMLHttpRequest (XHR) is an API that can be used by JavaScript, JScript, VBScript, and other web browser scripting languages to transfer and manipulate XML data to and from a webserver using HTTP, establishing an independent connection channel between a webpage's Client-Side and Server-Side.
The data returned from XMLHttpRequest calls will often be provided by back-end databases. Besides XML, XMLHttpRequest can be used to fetch data in other formats, e.g. JSON or even plain text.

AJAX - Action

This chapter gives you a clear picture of the exact steps of AJAX operation.

Steps of AJAX Operation

  • A client event occurs.
  • An XMLHttpRequest object is created.
  • The XMLHttpRequest object is configured.
  • The XMLHttpRequest object makes an asynchronous request to the Webserver.
  • The Webserver returns the result containing XML document.
  • The XMLHttpRequest object calls the callback() function and processes the result.
  • The HTML DOM is updated.
Let us take these steps one by one.

AJAX - Quick Guide