Tutorial by Examples

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 Devel...
Taken from jQuery.ajax API web site: $.ajax({ method: "POST", url: "some.php", data: { name: "John", location: "Boston" }, success: function(msg) { alert("Data Saved: " + msg); }, error: ...
Asynchronous ajax call With this type of ajax call, code does not wait for the call to complete. $('form.ajaxSubmit').on('submit',function(){ // initilization... var form = $(this); var formUrl = form.attr('action'); var formType = form.attr('method'); var formData ...
var httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = getData; httpRequest.open('GET', 'https://url/to/some.file', true); httpRequest.send(); function getData(){ if (httpRequest.readyState === XMLHttpRequest.DONE) { alert(httpRequest.responseText); } ...
Here is our function to create a simple ajax call written in vanilla javascript (not es2015): function ajax(url, callback) { var xhr; if(typeof XMLHttpRequest !== 'undefined') xhr = new XMLHttpRequest(); else { var versions = ["MSXML2.XmlHttp.5.0", ...
Adding a Product to a Shopping Cart The following example demonstrates how to Add a product (or anything) to a Database Table asynchronously, using AJAX, and TypeScript. declare var document; declare var xhr: XMLHttpRequest; window.onLoad = () => { Start(); }; function Start() { ...

Page 1 of 1