make ajax calls with jquery

Solutions on MaxInterview for make ajax calls with jquery by the best coders in the world

showing results for - "make ajax calls with jquery"
Michael
01 Nov 2019
1// GET Request
2    $.ajax({
3        url: "example.php?firstParam=Hello&secondParam=World", //you can also pass get parameters
4        dataType: 'json',	//dataType you expect in the response from the server
5        timeout: 2000
6    }).done(function (data, textStatus, jqXHR) {
7        //your code here
8    }).fail(function (jqXHR, textStatus, errorThrown) {
9        console.log("jqXHR:" + jqXHR);
10        console.log("TestStatus: " + textStatus);
11        console.log("ErrorThrown: " + errorThrown);
12    });
13
14//POST Request
15    var formData = {name: "John", surname: "Doe", age: "31"}; //Array 
16    $.ajax({
17        url: "example.php",
18        type: "POST", // data type (can be get, post, put, delete)
19        data: formData, // data in json format
20       	timeout: 2000,	//Is useful ONLY if async=true. If async=false it is useless
21        async: false, // enable or disable async (optional, but suggested as false if you need to populate data afterwards)
22        success: function (data, textStatus, jqXHR) {
23            //your code here
24        },
25        error: function (jqXHR, textStatus, errorThrown) {
26            console.log("jqXHR:" + jqXHR);
27            console.log("TestStatus: " + textStatus);
28            console.log("ErrorThrown: " + errorThrown);
29        }
30    });
31
32
33//Alternatively, the old aproach is
34    $.ajax({
35        url: "api.php?action=getCategories",
36        dataType: 'json',
37        timeout: 2000,
38        success: function (result, textStatus, jqXHR) {   //jqXHR = jQuery XMLHttpRequest
39            /*You could put your code here but this way of doing it is obsolete. Better to use .done()*/
40        },
41        error: function (jqXHR, textStatus, errorThrown) {
42            console.log("jqXHR:" + jqXHR);
43            console.log("TestStatus: " + textStatus);
44            console.log("ErrorThrown: " + errorThrown);
45        }
46    });
queries leading to this page
how to ajax call in jqueryhow to make an ajax requesteajax methods jqueryhow to put ajax call in functionajax call in jqueryjquery ajax on responsejquery ajax functionsjquery ajax then examplesimple jquery ajax statementcreate ajax function to call a funcionajax calling in jqueryjquery ajax examplesajax request in jqueryadd ajax in function and callmake ajax request jquerycall jquery ajaxwhich of the following jquery method can be used to make a ajax call call a function using ajaxjquery example ajaxsending ajax request with with jqueryjquer ajax callajax functions jqueryajax jquery javascript responsedo you use jquery with ajaxajax sample request jquerywhat script for ajax callwhy do we need ajax and jqueryhow to make an ajax requesthow to call ajax function from divcall javascript function ajaxajax query using jsjquery ajax request exampleajax example jqueryhow to make ajax requestsimple ajax request jqueryajax functions jquery example 24 28ajax 29 function 28 7bwhat does an ajax request do jqueryajax call jqueryhtml ajax example jquery jquery ajax functionajax method jquery explainedsimple ajax call in jqueryjquery handle ajax responsehow to use jquery with ajaxajax call in jquery tutorialajax request jquery examplemake ajax requestjquery ajax call examplehow to write ajax in jqueryjquery ajax methodswhat does an ajax request to jqueryuse ajax in jquerysample ajax call jquerydifferent ajax call jqueryhow to create ajax function in jquerycall ajax jqueryjquery ajax response functionajax with jqueryhow to use jquery html function in ajaxjquery ajax examplejquery function using ajaxhow to make an ajax callajax in jquery exampleajax function in jqueryjquery make ajax callwith 3fpage how can i make ajax requestcreate an ajax requesthow to handle jquery ajax callsjquery ajax examplemaking ajax call in javascriptcall java method from jquery using ajax examplehow to make ajax callajax call jquery syntaxajax call exampleshow to specify the method in ajax how to call javascript function in ajax responsejquery execute ajaxjquery when ajax as function callcreating ajax requesthow to call function in ajax jquery ajax function jquerymake ajax call in simple html pagewhat are the various ajax functions available in jqueryajax example in jqueryjavascript jquery ajax example ajax jquery examplethen in ajax call jqueryajax jquery functionhow to use ajax in jqueryajax call exampleajax jquery calljquery ajax exampleajax sample code jqueryjquery using ajaxajax call with jqueryjs ajax function callmake ajax callon ajax call jquerywhat are the various ajax functions available in jquery 3fhow to run ajax code in function from jqueryfunction ajax jqueryajax method in jqueryajax function in jquery methodajax jquery simple call examplejquery ajax when then examplejquery ajax callwhat are different ways to make ajax callsjavascript jquery ajax examplecall ajax using jqueryusing jquery and ajaxhow to call ajax inside ajaxajax calls in jqueryjquery ajax done exampleusing jquery ajaxjquery ajax sample codejquery and ajax requestinside js function need to ajax callmake an ajax call using jqueryajax request examplemaking ajax requestajax in a functionhow to make ajax request in jqueryhtml ajax call jquerycall ajax inside ajaxajax use in jqueryjquery methods ajaxrequest ajax in jquery 24 ajax 28 29 exampleajax setup jqueryhow to make js ajax requestajax using jqueryhtml jquery ajax exampleajax jquery callback functionswhat function do in ajax jquerrysteps on how to use ajax in jquerymaking an ajax requestjquery ajax callmake ajax call jqueryajax inside js functioncall jquery on ajax responsehow to use ajax call inside the ajax requestjquery use ajax in ajaxajax jquery function examplehow to write ajax call in jqueryhow to call ajax function with data from divput ajax call jqueryhow to use ajax response in jqueryjquery with ajaxjquery call ajaxexample jquery ajaxajax functionalityhtml jquery ajax callmake a request with ajaxhow to make an ajax call in jquery 24 ajax example jqueryajax jquery methodscall ajax function using jsjquery ajax method functionsajax call function in jqueryjquery ajax in functionjquery ajax methodcall ajax in functionhow to call javascript function from jquery ajaxhtml make ajax callsteps to write ajax in jqueryjquery ajax request methodjquery ajax call depend on its responsejquery ajax done functionexample call ajaxinject jquery code ajax responseajax calls with jqueryhow to use ajax with jqueryajax functionsmake ajax calls with jqueryhow to handle ajax call response in jqueryjquery ajax call optionsajax call in detailed in jquerywhy we request ajax in jqueryhow to call function in ajax in jacreating ajax callajax call jquery exampleajax inside ajax jqueyrajax call tutorialsample ajax call in jqueryjquery ajaxy js html pagemake an ajax requestjquery ajax request inusing jquery for ajaxuse ajax with jqueryajax jquery exampleajax code in jqueryjquery ajax samplehow to write an ajax call in jqueryjq ajax examplemaking ajax callsjquery apply ajax callsjquery simple ajax callajax call using jqueryajax calls jqueryjquery ajax funcitonmake ajax calls with jquery