0
votes

I am performing an ajax call from a .gsp file in grails:

$.ajax({
  async: false,
  url: '<g:createLink controller="mycontroller" action="myaction"/>',
  data: params,
  dataType: 'json',
  contentType: 'application/json; charset=utf-8',
  onSuccess: 'toggleSaveButton(false);'
});

mycontroller

def myaction() {
    // do some funky stuff with params
    // params are available, everything here works without a problem
}

outcome

the ajax call is performed and the controller function is called correctly with all attached data.

issue

my onSuccess: is ignored and never called

i already tried

  • using the more generic onComplete
  • change the onSuccess: to function(){toggleSaveButton(false);}
  • render (true as JSON) in my controller action
2

2 Answers

0
votes

I believe it should be success: instead of onSuccess:, according to JQuery ajax docs.

To demonstrate:

http://jsfiddle.net/bL60Lta9/2/

0
votes

Rewriting to :

onComplete: dataUpdatedOnSuccess()

did the trick.