Performs an AJAX request or asynchronous HTTP request.
$.ajax({
url: "https://api.example.com/data",
method: "GET",
success: function(response) {
// Handle the response data
},
error: function(xhr, status, error) {
// Handle errors
}
});
Sets the default values for future AJAX requests.
$.ajaxSetup({
headers: { "Authorization": "Bearer token" },
dataType: "json"
});
Loads data from the server using the GET HTTP request.
$.get("https://api.example.com/data", function(response) {
// Handle the response data
});
Fetches JSON-encoded data from the server using GET HTTP request.
$(selector).getJSON("https://api.example.com/data", function(data) {
// Handle the JSON data
});
Runs JavaScript using an AJAX HTTP GET request.
$(selector).getScript("script.js", function(response, status) {
// Script loaded and executed
});
Creates a serialized representation of an object.
var data = { name: "John", age: 30 };
var serializedData = $.param(data);
Loads data to the server using a POST HTTP request.
$.post("https://api.example.com/post", { data: "value" }, function(response) {
// Handle the response data
});
Specifies functions to run when an AJAX request completes.
$(document).ajaxComplete(function(event, xhr, options) {
// AJAX request completed
});
Specifies functions to run when an AJAX request fails.
$(document).ajaxError(function(event, xhr, options, exc) {
// Handle AJAX errors
});
Specifies functions to run when an AJAX request starts.
$(document).ajaxStart(function() {
// AJAX request started
});
Specifies functions to run when AJAX requests have been completed.
$(document).ajaxStop(function() {
// All AJAX requests completed
});
Loads data from the server and returns it into a selected element.
$(selector).load("content.html #target", function(response, status, xhr) {
// Content loaded into the selected element
});
Creates a text string in standard URL-encoded notation.
var formData = $(formSelector).serialize();
Creates a JavaScript array of objects to be encoded as a JSON string.
var formDataArray = $(formSelector).serializeArray();