I have the following Grails code:
${remoteFunction(controller: 'myController',
action: 'myMethod',
params: 'params',
onSuccess: 'mySuccessMethod(data);',
onComplete: 'myCompleteMethod();',
update: 'divName')};
I would expect:
mySuccessMethod()and myCompleteMethod()for each call are called once when the Ajax call ends
I get
mySuccessMethod() called immediately - When the Ajax call (eventually) ends
mySuccessMethod()called the second timemyCompleteMethod() called (once).
When looking for this problem, the Ajax recommendation was to use onsuccess, but the implementation (i.e. when it is called) seems different in Grails.
Can someone explain this.
- Why
mySuccessMethod()is it called twice? - Does this mean that we should use
onComplete, not onsuccessat least in Grails?
(: .)
HTML- remoteFunction() ( CR ):
jQuery.ajax({type:'POST',data:paramString,
url:'/<appname>/myController/myMethod',
success:function(data,textStatus){
jQuery('#divName').html(data);
mySuccessMethod(data);;
},
error:function(XMLHttpRequest,textStatus,errorThrown){
},
complete:function(XMLHttpRequest,textStatus){
myCompleteMethod();
}
});;
mySuccessMethod :
.