DO YOU NEED A CONTENT WRITER FOR YOUR BUSINESS?

Your One-Stop Solution for All Content Needs! Click here for more!
Categories: jQuery

jQuery AJAX Methods

Share

AJAX is an acronym standing for Asynchronous JavaScript and XML that is the art of exchanging data with a server without a browser page refresh.

jQuery is a great tool that provides a set of AJAX methods to develop the next generation of web application. This jQuery method is mostly used for requests where the other methods cannot be used.

Syntax:
$.ajax({name:value, name:value, ... })
Simple example:
$.ajax({
url: "ajax.php",
context: document.body
}).done(function() {
console.log('Done..');
});
$.ajax({
type:'GET',
url:'index.php',
dataType:'json',
data:"gender=male&age=25",
success:function(data){
console.log('Success..');
}
})

Here are possible names/values:

Name Value
async A Boolean value indicating whether the request should be handled asynchronous or not. Default is true
cache A Boolean value indicating whether the browser should cache the requested pages. Default is true
beforeSend(xhr) A function to run before the request is sent
contentType The content type used when sending data to the server. Default is: “application/x-www-form-urlencoded”
complete(xhr,status) A function to run when the request is finished (after success and error functions)
data Specifies data to be sent to the server
context Specifies the “this” value for all AJAX related callback functions
dataType The data type expected of the server response.
dataFilter(data,type) A function used to handle the raw response data of the XMLHttpRequest
global A Boolean value specifying whether or not to trigger global AJAX event handles for the request. Default is true
error(xhr,status,error) A function to run if the request fails.
jsonp A string overriding the callback function in a jsonp request
ifModified A Boolean value specifying whether a request is only successful if the response has changed since the last request. Default is: false.
password Specifies a password to be used in an HTTP access authentication request.
jsonpCallback Specifies a name for the callback function in a jsonp request
scriptCharset Specifies the charset for the request
processData A Boolean value specifying whether or not data sent with the request should be transformed into a query string. Default is true
timeout The local timeout (in milliseconds) for the request
success(result,status,xhr) A function to be run when the request succeeds
type Specifies the type of request. (GET or POST)
traditional A Boolean value specifying whether or not to use the traditional style of param serialization
xhr A function used for creating the XMLHttpRequest object
username Specifies a username to be used in an HTTP access authentication request
url Specifies the URL to send the request to. Default is the current page

For more details click on jQuery documentation.

Jacob Frazier

Based on United States, Jacob Frazier is a skilled JavaScript developer with over 8 years of experience. He is passionate about change and trying new things, both professionally and personally. He loves startups and is extremely proactive.

Recent Posts

Writing Tools That Help Content Marketers Produce Cleaner Work

Content marketing has a hidden tax. It's not the writing itself, it's everything that happens…

7 days ago

How Data Analytics Is Actually Driving Smarter Marketing Decisions

Most marketing teams aren't failing because they lack data. They're failing because they can't act…

2 weeks ago

The Ultimate SPF Tester Guide: Boost Email Deliverability In Minutes

Email marketing continues to be one of the most effective ways for businesses to communicate,…

2 weeks ago

Sales Ops: A role that helps sales teams work as efficiently as possible

Xerox first introduced it around the mid-1970s. The need came up because the management activities…

3 weeks ago

Forex Investment Tips for Beginners

Investing in the forex market may look to be a dangerous game. With some worthwhile…

4 weeks ago

How Did The Restaurant Industry change In Post Pandemic Era?

The coronavirus outbreak has drastically changed the way we live our lives. Yes, that's absolutely…

1 month ago