JQuery Advanced Concepts

Level : Advanced
Mentor: Shailendra Chauhan
Duration : 00:00:40

jQuery.ajax()

Performs an AJAX request or asynchronous HTTP request.

Example:

$.ajax({
  url: "https://api.example.com/data",
  method: "GET",
  success: function(response) {
    // Handle the response data
  },
  error: function(xhr, status, error) {
    // Handle errors
  }
});

jQuery.ajaxSetup()

Sets the default values for future AJAX requests.

Example:

$.ajaxSetup({
  headers: { "Authorization": "Bearer token" },
  dataType: "json"
});

jQuery.get()

Loads data from the server using the GET HTTP request.

Example:

$.get("https://api.example.com/data", function(response) {
  // Handle the response data
});

jQuery.getJSON()

Fetches JSON-encoded data from the server using GET HTTP request.

Example:

$(selector).getJSON("https://api.example.com/data", function(data) {
  // Handle the JSON data
});

jQuery.getScript()

Runs JavaScript using an AJAX HTTP GET request.

Example:

$(selector).getScript("script.js", function(response, status) {
  // Script loaded and executed
});

jQuery.param()

Creates a serialized representation of an object.

Example:

var data = { name: "John", age: 30 };
var serializedData = $.param(data);

jQuery.post()

Loads data to the server using a POST HTTP request.

Example:

$.post("https://api.example.com/post", { data: "value" }, function(response) {
  // Handle the response data
});

.ajaxComplete()

Specifies functions to run when an AJAX request completes.

Example:

$(document).ajaxComplete(function(event, xhr, options) {
  // AJAX request completed
});

.ajaxError()

Specifies functions to run when an AJAX request fails.

Example:

$(document).ajaxError(function(event, xhr, options, exc) {
  // Handle AJAX errors
});

.ajaxStart()

Specifies functions to run when an AJAX request starts.

Example:

$(document).ajaxStart(function() {
  // AJAX request started
});

.ajaxStop()

Specifies functions to run when AJAX requests have been completed.

Example:

$(document).ajaxStop(function() {
  // All AJAX requests completed
});

.load()

Loads data from the server and returns it into a selected element.

Example:

$(selector).load("content.html #target", function(response, status, xhr) {
  // Content loaded into the selected element
});

.serialize()

Creates a text string in standard URL-encoded notation.

Example:

var formData = $(formSelector).serialize();

.serializeArray()

Creates a JavaScript array of objects to be encoded as a JSON string.

Example:

var formDataArray = $(formSelector).serializeArray();
Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this