More about jQuery AJAX

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

jQuery made AJAX simple by using .ajax() function.
The syntax for this function is:

$.ajax( /* properties */);

Now let me explain what properties we can use in this function.

First, I would like to tell you what basic (standard) options for .ajax() as follow:
Properties:
– url: String /* The URL to send the request to */
– type: String /* The request type (“GET”, “POST”) */
– contentType: String /* default: “application/x-www-form-urlencoded” */
– data: Object, String /* Data to be sent to the server. It is converted to a query string, if not already a string. It’s appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key i.e. {foo:[“bar1”, “bar2”]} becomes ‘&foo=bar1&foo=bar2’ */

Events:
– beforeSend: Function /* This function runs just before sending the request */
– success: Function /* This is an important part. Here we run the code because the request is done */
– complete: Function /* This function runs after the success is done and errors are shown */
– error: Function /* This function runs when error occurred
function(ajaxHnadler,eventHandler){
// ajaxHandler: xmlHTTP object
// eventHandler: handles the event as string
*/
– timeout: Function /* runs when request is timed out */

There are more options, you can check them on jQuery website.
Actually, I cannot create a demo to test all mentioned properties and methods… So, if you experienced a problem or need some help, please contact me.

For more information about jQuery AJAX Please visit: click here.
You can also read about .GET and .POST

By Alaa Badran

Front-End and Web developer

8 replies on “More about jQuery AJAX”

Leave a Reply

Your email address will not be published. Required fields are marked *