$(function(){
jQuery.extend({
put: function( url, data, callback, type ) {
// shift arguments if data argument was omited
if ( jQuery.isFunction( data ) ) {
type = type || callback;
callback = data;
data = {};
}
return jQuery.ajax({
type: "PUT",
url: url,
data: data,
success: callback,
dataType: type
});
},
del: function( url, data, callback, type ) {
// shift arguments if data argument was omited
if ( jQuery.isFunction( data ) ) {
type = type || callback;
callback = data;
data = {};
}
return jQuery.ajax({
type: "DELETE",
url: url,
data: data,
success: callback,
dataType: type
});
}
})
jQuery.each( [ "get", "post","put","del"], function( i, method ) {
// jQuery.get或jQuery.post为
jQuery[ method ] = function( url, data, callback, type ) {
if($("#loading")){
$("#loading").show()
}
var callbackafter = function(){
if($("#loading")){
$("#loading").hide()
}
callback.call(window,arguments[0]);
}
// 模拟重载
if ( jQuery.isFunction( data ) ) {
type = type || callback;
callback = data;
data = undefined;
}
// 利用jQuery.ajax完成任务
return jQuery.ajax({
url: url,
type: method,
dataType: type,
data: data,
success: callbackafter
});
};
});
})()
function disableAop(){
jQuery.each( [ "get", "post","put","del"], function( i, method ) {
// jQuery.get或jQuery.post为
jQuery[ method ] = function( url, data, callback, type ) {
// 模拟重载
if ( jQuery.isFunction( data ) ) {
type = type || callback;
callback = data;
data = undefined;
}
// 利用jQuery.ajax完成任务
return jQuery.ajax({
url: url,
type: method,
dataType: type,
data: data,
success: callback
});
};
});
}