AJAX is a web development technique for creating interactive web applications. If you know JavaScript, HTML, CSS, and XML, then you need to spend just one hour to start with AJAX.

EXAMPLE

// This is the client-side script.

// Initialize the HTTP request.
var xhr = new XMLHttpRequest();
xhr.open(‘GET’, ‘send-ajax-data.php’);

// Track the state changes of the request.
xhr.onreadystatechange = function () {
var DONE = 4; // readyState 4 means the request is done.
var OK = 200; // status 200 is a successful return.
if (xhr.readyState === DONE) {
if (xhr.status === OK) {
console.log(xhr.responseText); // ‘This is the output.’
} else {
console.log(‘Error: ‘ + xhr.status); // An error occurred during the request.
}
}
};

// Send the request to send-ajax-data.php
xhr.send(nul

 

HOW DOES IT WORKS ?

To get data on the server, XMLHttpRequest provides two methods:

  • open: create a connection.
  • send: send a request to the server.

Data furnished by the server will be found in the attributes of the XMLHttpRequest object:

  • responseXml for an XML file or
  • responseText for a plain text.

   PLUGINS

      A jQuery plugin is simply a new method that we use to extend jQuery’s prototype object. By extending the prototype object you enable all        jQuery objects to inherit any methods that you add. As established, whenever you call jQuery() you’re creating a new jQuery object, with          all of  jQuery’s methods inherited.

      The idea of a plugin is to do something with a collection of elements. You could consider each method that comes with the jQuery core a         plugin, like .fadeOut() or .addClass().

      BENEFITS

  • Callbacks: Ajax is used to perform a callback, making a quick round trip to and from the server to retrieve and/or save data without posting the entire page back to the server. By not performing a full post back and sending all form data to the server, network utilization is minimized and quicker operations occur. In sites and locations with restricted bandwidth, this can greatly improve network performance. Most of the time, the data being sent to and from the server is minimal. By using callbacks, the server is not required to process all form elements. By sending only the necessary data, there is limited processing on the server. There is no need to process all form elements, process the ViewState, send images back to the client, or send a full page back to the client.
  • Making Asynchronous Calls: Ajax allows you to make asynchronous calls to a web server. This allows the client browser to avoid waiting for all data to arrive before allowing the user to act once more.
  • User-Friendly: Because a page post back is being eliminated, Ajax enabled applications will always be more responsive, faster and more user-friendly.
  • Increased Speed: The main purpose of Ajax is to improve the speed, performance and usability of a web application. A great example of Ajax is the movie rating feature on Netflix. The user rates a movie and their personal rating for that movie will be saved to their database without waiting for the page to refresh or reload. These movie ratings are being saved to their database without posting the entire page back to the server.

    LIMITATIONS

  • While Ajax is a web application development technique that is designed to make web pages more responsive and interactive with a user, Ajax has some limitations to consider before you develop an Ajax-based application. The following limitations are some of the more prominent disadvantages:
  • Browser support – Not all browsers support JavaScript or XMLHttpRequest object. Even among browsers that do have support for JavaScript and XMLHttpRequest, these objects can be treated differently. Each browser’s implementation of Ajax must be considered.
  • Security and user privacy – Not all concerns are addressed. Issues surrounding security and user privacy need to be considered when developing an Ajax application.
  • Accessibility – Because not all browsers have JavaScript or XMLHttpRequest object support, you must ensure that you provide a way to make the web application accessible to all users.
  • Bookmark and navigation – Since Ajax is used to asynchronously load bits of content into an existing page, some of the page information may not correspond to a newly loaded page. Browser history and bookmarks may not have the correct behavior since the URL was unchanged despite parts of the page being changed.
  • Search engine – Ajax applications are not searchable; however, it is possible to use Ajax features and elements within an application that is searchable.

     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.

     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.
Get a Quote info@websitetoon.com