You essentially set up your plugin as follows:
( function($) { $.fn.doSomething = function() {
... and therefore there is a plugin that works with jQuery objects. So this will work:
$('#something').doSomething();
But you call it like this:
$.doSomething();
Since you obviously want your function to stand alone in the jQuery namespace, you would set it like this:
$.doSomething = function(){
So, in the case of your code, try adding this below, right above the end of your function:
$.myAjax = $.fn.myAjax;
As a side note, it is not recommended to use more than one namespace for your plugin ( ajaxDefaults from your example). You should quickly read the jQuery 's Create Plugin page for some useful tips.
source share