$.ajaxSetup({
success: function onSuccess(msg) {
// add some functions to `msg`
// then return to success method that defined in $.ajax
msg.display = function(){
alert(msg.M_Prop);
}
return msg;
}
});
$.ajax({
success: function(newMsg){
// call new functions of newMsg object
newMsg.display();
}
});
$.ajaxSetup({ success: function onSuccess(msg) { // add some functions to `msg` // then return
Share
How about this?
I’ve tested it here on jsfiddle
Here’s another way (the way you want it)
Tested this here