jQuery AJAX Complete Reference (original) (raw)
Last Updated : 23 Jan, 2023
AJAX is a technique, not a programming language that is used by developers to make websites behave like desktop applications. It operates on the client-side for creating asynchronous web applications. AJAX is a group of technologies that uses a number of web technologies for creating a set of web development techniques.
jQuery provides various methods for AJAX functionality. There are some jQuery AJAX methods that are used to request text, HTML, XML, or JSON from a remote server using both HTTP Get and HTTP Post.
Syntax:
$.ajax_method(parameter1, parameter2, ..)
Example: This example use param() method to create serialized representation of an object.
HTML `
jQuery param() Method<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<h1 style="color:green;">
GeeksForGeeks
</h1>
<h2>jQuery param() Method</h2>
<button>Click</button>
<div></div>
<!-- Script using param() method -->
<script>
$(document).ready(function() {
personObj = new Object();
personObj.Firstword = "Geeks";
personObj.Secondword = "For";
personObj.Thirdword = "Geeks";
personObj.Wordcolor = "Green";
$("button").click(function() {
<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">(</mo><mi mathvariant="normal">"</mi><mi>d</mi><mi>i</mi><mi>v</mi><mi mathvariant="normal">"</mi><mo stretchy="false">)</mo><mi mathvariant="normal">.</mi><mi>t</mi><mi>e</mi><mi>x</mi><mi>t</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">("div").text(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mopen">(</span><span class="mord">"</span><span class="mord mathnormal">d</span><span class="mord mathnormal">i</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord">"</span><span class="mclose">)</span><span class="mord">.</span><span class="mord mathnormal">t</span><span class="mord mathnormal">e</span><span class="mord mathnormal">x</span><span class="mord mathnormal">t</span><span class="mopen">(</span></span></span></span>.param(personObj));
});
});
</script>
`
Output:
jQuery AJAX Method Complete Reference:
Methods | Description |
---|---|
ajax() | Perform an AJAX request or asynchronous HTTP request. |
ajaxSetup() | Set the default values for future AJAX requests. |
get() | Loads data from the server by using the GET HTTP request. |
getJSON() | Fetches JSON-encoded data from the server using a GET HTTP request. |
parseJSON() | Takes a well-formed JSON string and returns the resulting JavaScript value. |
getScript() | Run a JavaScript using AJAX HTTP GET request. |
param() | Create a serialized representation of an object. |
post() | Returns an XMLHttpRequest object. |
ajaxComplete() | Specify a function to be run when an AJAX request completes. |
ajaxError() | Specify a function to be run when an AJAX request fails. |
ajaxSend() | Specify the function to be run when an AJAX request is about to send. |
ajaxStart() | Specify a function to be run when an AJAX request starts. |
ajaxStop() | Specify a function to be run when AJAX requests have been completed. |
ajaxSuccess() | Specify the function to be run when an AJAX request is completed successfully. |
load() | It is a simple but very powerful AJAX method. |
serialize() | Create a text string in standard URL-encoded notation. |
serializeArray() | Create a JavaScript array of objects that is ready to be encoded as a JSON string. |