jQuerys Ajax module.

jQuerys Ajax module.

Hey guys , i have never used much of jquerys ajax module , now i was just going through the documentation for $.ajax HERE . has alot of interesting features eg.

  1. statusCode (default: {})
  2. Type: PlainObject
  3. An object of numeric HTTP codes and functions to be called when the response has the corresponding code. For example, the following will alert when the response status is a 404:

  4. $.ajax({
  5.   statusCode: {
  6.     404: function() {
  7.       alert( "page not found" );
  8.     }
  9.   }
  10. });
  11. If the request is successful, the status code functions take the same parameters as the success callback; if it results in an error (including 3xx redirect), they take the same parameters as the error callback.
So i believe if a page does't exist , you can write your own code to handle the situation. GREAT ! 

I was primarily concerned with what can be done with the success function , what innovative stuff can you do with it ?  so far i have done stuff very basic , like.

  1. $.ajax({
  2.                         type        : 'POST', // define the type of HTTP verb we want to use (POST for our form)
  3.                         url         : 'inc/database.php', // the url where we want to POST
  4.                         data: formData,
  5.                         // THIS MUST BE DONE FOR FILE UPLOADING
  6.                         contentType: false,
  7.                         processData: false,
  8.                         // ... Other options like success and etc

  9.                         success: function(data) {
  10.                             $('body').append('<div class="ajax-success"><p>Its Done !!!</p></div>');
  11.                         }
  12.                 });
even if i google , i get pretty basic examples :D