ajax programming

Solutions on MaxInterview for ajax programming by the best coders in the world

showing results for - "ajax programming"
Mae
09 Mar 2017
1 $.ajax({
2    type: 'GET',
3    dataType: 'json',
4    url: url,
5    timeout: 5000,
6    success: function(data, textStatus ){
7       alert('request successful');
8    },
9    fail: function(xhr, textStatus, errorThrown){
10       alert('request failed');
11    }
12  });
13
Marta
19 Jun 2018
1// For a plain JS solution, use these functions:
2
3function _GET_REQUEST(url, response) {
4  var xhttp;
5  if (window.XMLHttpRequest) {
6    xhttp = new XMLHttpRequest();
7  } else {
8    xhttp = new ActiveXObject("Microsoft.XMLHTTP");
9  }
10
11  xhttp.onreadystatechange = function() {
12    if (this.readyState == 4 && this.status == 200) {
13      response(this.responseText);
14    }
15  };
16
17  xhttp.open("GET", url, true);
18  xhttp.send();
19}
20
21function _POST_REQUEST(url, params, response) {
22  var xhttp;
23  if (window.XMLHttpRequest) {
24    xhttp = new XMLHttpRequest();
25  } else {
26    xhttp = new ActiveXObject("Microsoft.XMLHTTP");
27  }
28
29  xhttp.onreadystatechange = function() {
30    if (this.readyState == 4 && this.status == 200) {
31      response(this.responseText);
32    }
33  };
34
35  xhttp.open("POST", url, true);
36  xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
37  xhttp.send(params);
38}
39
40// and apply like this:
41_GET_REQUEST('http://someurl', (response) => {
42	// do something with variable response
43});
44_POST_REQUEST('http://someurl', 'paramx=y', (response) => {
45	// do something with variable response
46});
Valentina
06 May 2019
1With Ajax, web applications can send and retrieve data from a server asynchronously without interfering with the display and behaviour of the existing page.
Luis
21 Jan 2016
1// BEGIN
2// JavaScript example
3// An example of a simple Ajax request using the GET method, written in JavaScript.
4
5// get-ajax-data.js:
6
7// This is the client-side script.
8// Initialize the HTTP request.
9var xhr = new XMLHttpRequest();
10xhr.open('GET', 'send-ajax-data.php');
11
12// Track the state changes of the request.
13xhr.onreadystatechange = function () {
14	var DONE = 4; // readyState 4 means the request is done.
15	var OK = 200; // status 200 is a successful return.
16	if (xhr.readyState === DONE) {
17		if (xhr.status === OK) {
18			console.log(xhr.responseText); // 'This is the output.'
19		} else {
20			console.log('Error: ' + xhr.status); // An error occurred during the request.
21		}
22	}
23};
24
25// Send the request to send-ajax-data.php
26xhr.send(null);
27// END
28
29// BEGIN
30// send-ajax-data.php:
31<?php
32// This is the server-side script.
33// Set the content type.
34header('Content-Type: text/plain');
35
36// Send the data back.
37echo "This is the output."; ?>
38// END 
39  
40// BEGIN  
41// Fetch is a new native JavaScript API  
42fetch('send-ajax-data.php')
43    .then(data => console.log(data))
44    .catch (error => console.log('Error:' + error));
45// END
46
47// BEGIN
48// ES7 async/await example:  
49async function doAjax() {
50    try {
51        const res = await fetch('send-ajax-data.php');
52        const data = await res.text();
53        console.log(data);
54    } catch (error) {
55        console.log('Error:' + error);
56    }
57}
58
59doAjax();
60// END
queries leading to this page
ajax 3fajax javascripttuhow to make ajax call in javascripthow to use ajax javascript 24 ajax explainedajax 28programming 29ajax for javascriptajax in jasbasic ajax htmlajax language 24 ajaxajaxq javascriptajax infohow ajax js worksajax 2020 javascriptajax call jsis ajax part of html5ajax programming like langugageajax architectureprogramming ajaxthe open and send methods are used in every single ajax application written in javascriptajax basic jsajax data call by name htmlajax syntaxuse ajax without xmlajax programming logouse ajax in javascriptapi javascript ajaxajax programmigdo you need ajaxjs 3f ajaxjavascritp ajaxajax w3chow to use html ajax and cssjavascirp ajaxjavascrip ajaxjquery ajaxajax call in javascript propertries neededajax meaning jsajax javaajax calls 2casynchronous javascript and xmlajax client server architecturew3w ajax callajax using jsajax definition jsajax call to api w3how to do an ajax call in javascriptjs ajaxhtml ajaxset up ajaxajax html call 24 ajax exaplinedajax client sideuse ajax call in javascriptjavascript ajax jqueryajax tutorilawhere to code for ajaxajax code ajax javascript jqueryjavascript use ajaxajax programming what isajax 28programa c3 a7 c3 a3o 29ajax for beginners 24 ajax javascriptajax javascript official website urlajax javascripthow to use ajax in jshow ajax workajax call from javascript sidejava script ajax functionajax tutorialnodejs ajaxstandards for ajax requestswhat is js ajaxjavascript ajax methodajax httplearning ajaxjavascript ajax requestajax or apihow to learn ajax step by stepplain js ajaxajax linksjavascrip 24 ajax ajaxajax jquerjquer ajaxjavascript to ajax 24 ajax 28what is ajax in programming 3fjquery script with ajax functionajax call tutorialaajax web devajax syntextjavascript ajazajax js jqueryajax jscript 24 ajax in javascriptwhat is ajax in web developmentcomplete js ajax tutorial 2020javascript and ajax are used to design server side applicationin ajax you canjaquery ajaxjavascript ajax apiis ajax a programming languageajax 27ajax developmentjs ajax requestajax code examplewhat is ajax programmingajax call 24 ajaxajax modeajax jquery javascriptajax docswhat is ajax request in javascriptimport ajax into javascriptajax asynchronousfull ajaxajax in codeajax meaning programmingdemonstrate the use of ajax and json technologies in programming examples js in ajaxajax request to websitewhat is ajax in web programmingajax in javascript example 24 ajax 28 7bjavascript 24 ajax 28 29ajax versionwrite a simple ajax applicationwhat is ajax javascriptajax pageswhere to write ajax code in htmlajax codeejs api ajaxajax w3schoolajax framework ajaxajax w3schoolsajax latest versionajax codesusing ajax with javascript ajax javascriptajax call programmewhat are the basic ajax requestis ajax javascriptsite for call ajaxajax is jsajax in vanila jscreate html page from ajax requestajax programimngajax html5make interactive website using http 2c javascript 2c xml 2c ajaxajax in web developmentjs ajazjavascript e2 80 93 ajaxajax jsjavascript ajax nedirajax programingajax programming meaninginteractive links ajaxajax web browserajax programminghow to learn ajaxsimple ajax call in javascriptajax serverintro to ajaxajax javascript librarywhat is ajax jswaht is ajax javascriptajax webajax in javascriptwhich of the following can ajax 28asynchronous javascript and xml 29 not be used for 3fajax syntax jsajax jwhat is ajax is programmingajax code 5dajax programming languageajax js requestajax reuest in htmlajax js ajax jsraphaeljs ajaxajax codformat and protocol of ajaxwhat is ajax in codingvanilla js ajaxajax by w3schoolsuse ajax jsajax web programming how to implement ajax in javascriptgetting started with ajaxajax full formjs ajax jquerylearn ajaxajax programming partsjquery ajax javascriptajax programming tutorial 2020htm ajaxajax in web technologyajax javascihow to use ajax jsajax is web technicajax code in jqueryajax versionconnect ajaxwhat is ajax codingsample ajax serverajax javascript jqueryajax using javascript 287 29 define ajax how to improve a webpage using ajax 3f explain with example what is ajax programming language 3fajax explanationhow works ajaxajax is a programming languageajax javscriptmaking an ajax call in javascriptprogramming what is ajaxajax learninagwhere to run aajaxhow to connect html and ajax ajax programming functionjavascript ajaxdo ajax call in javascripthow to code ajaxajaxa jshow to write ajax call in javascriptajax code official websitewhat is ajax webajax meaning javascriptajax in javascriptjavscript ajaxwhat is ajax in jsapi ajaxwhat is ajax web developmentajax domajax in programmingjavascript ajaxcreate ajax onlineajax claljquery ajax codejavascript ajax codeajax jaavscriptis ajax jsajax javascrptajax in javascript meaningjavascript ajax supporthow to use 24 ajaxajax keyword referencejavascript ajaxgoogle ajax tutorialjavascript 24 ajaxhow to use ajax in javascript functionajax api javascripthow to ajaxajax codingajax basicsajax javascript what isajax programming js 24 ajax how towhat is ajax in javascriptunderstand ajaxhow to impolement ajax in a documenthtml5 ajaxdoes ajax is document encoded 3f 22 24 ajax 22dom ajaxjs what is ajaxajax javascript tutorialjavascript jquery ajaxjsf ajaxframework javascript ajax ajax 28 7b 7d 29ajax scriptbasic ajaxajax programmlingajax in jsjs ajax when ajax brwser proccessajax calls in javascriptuse ajax in htmlajax how toajax programming