i’m using single ajax method all over my site and i need to parametrize all params and options, also callback methods (success,beforeSend,error, etc ..)
for now i wrote:
function ajax(_type,_url,_data,_dataType,_starter,_callback_success,_callback_error, etc ..){
$.ajax({
type:_type,
data:_data,
dataType:_dataType,
url:'http://localhost:9292/'+_url,
success: _callback_success,
error: _callback_error,
// etc ...
});
}
after that i would like to use this method in this way for example:
ajax(
'GET',
users,
{},
'json',
false,
function(){
alert(json);
});
i don’t know how can i parametrize statuses (success,error,BeforeSend)? i’m trying with simple vars _callback_error or _callback_success but it’s not clear to me how to pass callbacks in statuses
hope is clear my question
Jquery will pass those into the callbacks when it invokes them.
Here’s an example usage of your function.