Imdad
Imdad

Reputation: 6042

How can I extend jquery's .ajax() and create custom .ajax2() for my use

I want to extend the Ajax functionality of JQuery for having advanced options and features.

For example i could pass an argument named logElement and pass a selector to find the element to place log.

like

$.ajax({
    type: "GET",
    url: "ajax/get_countries.php",
    dataType: 'json',
    logElement:"#logDiv",
    success: function(data){
           //code
        }

});

This should function like jquery's Ajax request and also print log information in the specified logElement on success and error

Upvotes: 1

Views: 256

Answers (1)

xCander
xCander

Reputation: 1337

(function($) {

  $.ajax2 = function(settings) {
    // do what you want...
    $.ajax(settings);
  };

})(jQuery);

Upvotes: 2

Related Questions