Reputation: 31
as for now i have 97 same functions like this:
function member_requestDetail(member_id){
$.ajax({
type: 'POST',
url: 'action.php',
data: 'action=55&member_id='+member_id,
success: function(msg){
if(msg){
var Sresponse=eval('(' + msg + ')');
if(Sresponse.status=='success'){
detailWindow.innerHTML=Sresponse.memberDetails;
}
else{if(Sresponse.status=='error'){
detailWindowError.innerHTML=Sresponse.errorText;
}}
}
else{
detailWindowError.innerHTML='Error';
}
}
});
}
i was wandering if i do something like this:
function requestAction(actionID,dataToSend,callback,error_callback){
$.ajax({
type: 'POST',
url: 'action.php',
data: 'action='+actionID+dataToSend,
success: function(msg){
if(msg){
var Sresponse=eval('(' + msg + ')');
callback(Sresponse);
}
else{
error_callback();
}
}
});
}
would it lose speed or something? do i have to do multithreading then or anything? example if function requestAction gets multiple calls in a seccond.
hope someone understands!
thanks for help
Upvotes: 0
Views: 113
Reputation: 33650
There should not be a noticeable performance impact to the approach you outlined, even if requestAction()
gets multiple calls per second. You're only adding the overhead of one additional function call on the stack.
Upvotes: 2