Can I use these extended request params in the service success event also?
My goal is to 'label' a service.execute execution. So I have a for-loop:
precode
for (var counter=0; counter < x.length; counter++){
Code: Select all
service.execute({
data: {
"executionNumber": counter
}
});
}
/code/pre
So the goal is now that this "executionNumber" is available to the service SUCCESS event, so the service success event knows which iteration the service call was.
Note that I can not change the service itself, to just add this request parameter in its service response, because the service response parameters are fixed because the online service is not under my control.
So maybe my approach to add a request parameter to the service is wrong, because the server expects a fixed request parameter pattern.
Do you have a solution to "add" some data to a service execution, that can be used in the success event?
I can't do it with a localstorage variable, because the localstorage variable would be overwritten by the next iteration of the for-loop BEFORE the service response of the first iteration was completed. So then the service success event would get a wrong localstorage variable. (because of asynchronity of ajax calls)
A solution could be to "overwrite" the success callback function, and add a parameter to this function! Can this be done with the service.execute call? For example:
precode
service.execute({
data: {
success: function(data, MYPARAMETER) { ... }
}
})
/code/pre