Getting started with ajax


AJAX (asynchronous JavaScript and XML) allows you to request external data without blocking the execution of code. In many cases this is implemented in requesting pieces of a page or information from a server (via XMLhttpRequests) and then processing and displaying it using javascript.

The non-blocking nature of AJAX is what makes it such a widespread software pattern. Since javascript is blocking in the browser, a synchronous external call would make the browser unresponsive for the duration of the call until it either returned data or timed out. In effect making your application entirely dependent on external architecture and how well it will perform.

AJAX calls are usually abstracted out to provide additional functionality or readability, but implementations are (usually) built upon the XMLHttpRequest Specification.

Installation or Setup

What is AJAX?

AJAX stands for Asynchronous JavaScript and XML. In a nutshell, it is the use of the XMLHttpRequest object to communicate with server-side scripts. It can send as well as receive information in a variety of formats, including JSON, XML, HTML, and even text files. -Mozilla Developer Network 2016

The easiest way of implementing AJAX, especially if you’re planning on communicating with servers is by using jQuery.

What is jQuery?

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. -jquery.com

For those who haven’t used much jQuery, think of it as functions that we can use to make our lives easier. This is perfect for using with AJAX as it cuts down on the amount of code we have to write to accomplish the same thing!

How to Add jQuery to your web site

If you need to Use Ajax, you need to add jQuery to your project. https://jquery.com/download/ In This link you can see many ways to add jquery. You can use downloaded version of jQuery or you can use a CDN. https://jquery.com/download/#jquery-39-s-cdn-provided-by-maxcdn. But there is some security risk if you uses CDN. Becauese the project call out to use jquery, so a hacker could manipulate the call. So better if you could use downloaded version. Lets see how to add jquery to html project. It’s easy. First example is to use Downloaded source. Use this link to https://jquery.com/download/#jquery download. If you are just want to use jquery, I suggest you to download Download the compressed, production jQuery 3.1.1 When you download it add jquery-version.min.js to appropriate place (like javascript folder of your project) Then just add