I’m trying to pass the name of a javascript function to a global variable. I have a generic “CallMyWebService” function built around $.ajax(). The function’s url, verb, contenttype, etc. are set based on the value of global variables. Immediately before the service function is called, the globals are set and after the globals reset to nothing.
My generic “CallMyWebService” function is here:
function CallMyWebService() {
$.ajax(
{
url : varUrl,
type : varHttpVerb,
cache : varCacheBool,
data : varData,
contentType : varContentType,
processdata : varProcessData,
dataType : varDataType,
async : varAsync,
success : varOnSuccess,
error : varOnError,
complete : varOnComplete
}
)
}
The problem I’m having is passing the function names to varOnSuccess, varOnError, and varOnComplete. If I have a function named SuccessCallback() and I want the the result of the service call passed to SuccessCallback(), how do I assign it to the varOnSuccess global variable? The variable assignment will take place in another function called SetupServiceCall(). In other words, in the SetupServiceCall() function how should varOnSuccess = be completed?
I would say:
Look in the jQuery documentation for details on the parameters that SuccessCallback() will receive.