JeffW
JeffW

Reputation: 186

Grails RemoteFunction creates bad javascript

I am taking over a project from an engineer that left my company, and am having to quickly come up to speed on Grails, so if this is a noob question, well, I'm a noob.

In one of one of my GSP files, I've got a remoteFunction call in the middle of a javaScript function:

function fnCreateEntitiesPerForceChart() {
      var interval = $("#entitiesPerForceTimeIntervalSelect").val();
      var url = '${createLink(controller: 'federation', action: 'createEntitiesPerForceChart')}?interval='+escape(interval);
      $("#entitiesPerForceChart").attr("src", url);

      ${remoteFunction(controller: 'federation', 
        action: 'getEntitiesPerForceTable', 
        params: '\'interval=\'+interval', 
        onSuccess: 'fnUpdateEntitiesPerForceTable(data,textStatus)')}; 
    }

That remoteFunction call is being sent to the client as:

try{DojoGrailsSpinner.show();}catch(e){} dojo.xhr('Get',{content:{'interval='+interval}, preventCache:true, url:'/FederationReporter/federation/getEntitiesPerForceTable', load:function(response){ fnUpdateEntitiesPerForceTable(data,textStatus); }, handle:function(response,ioargs){try{DojoGrailsSpinner.hide();}catch(e){} }, error:function(error,ioargs){try{DojoGrailsSpinner.hide();}catch(e){} } });;

Which is causing a error: SyntaxError: missing : after property id ...){} dojo.xhr('Get',{content:{'interval='+interval}, preventCache:true, url:'/Fed...

federation (line 400, col 60) (which is the bolded '+' before the second 'interval'

What am I missing?

Upvotes: 0

Views: 245

Answers (1)

dmahapatro
dmahapatro

Reputation: 50245

Dojo content should be a key-value pair.

{content:{'interval': interval}

Upvotes: 1

Related Questions