grails remotefunction:无法访问params

时间:2013-04-25 15:18:34

标签: javascript ajax grails dojo

我的GSP文件中的javaScript函数中有一个remoteFunction调用:

function fnCreateEntitiesPerForceChart() {
      var interval = $("#entitiesPerForceTimeIntervalSelect").val();
      interval = escape(interval);
      var url = '${createLink(controller: 'federation', action: 'createEntitiesPerForceChart')}?interval='+interval;
      $("#entitiesPerForceChart").attr("src", url);
alert("interval is: " + interval);
      ${remoteFunction(controller: 'federation', 
        action: 'getEntitiesPerForceTable', 
        params: '\'interval\''+':'+interval, 
        onSuccess: 'fnUpdateEntitiesPerForceTable(data,textStatus)')}; 
    }

当我检查页面源时,remotefunction会创建以下代码:

try{DojoGrailsSpinner.show();}catch(e){} dojo.xhr('Get',{content:{'interval':null}, 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){}  } });; 

为什么我的变量被'null'替换?

谢谢!

2 个答案:

答案 0 :(得分:0)

params来电

中将其设为remoteFunction

params: '\'interval\': + interval'

答案 1 :(得分:0)

试试这个:

function fnCreateEntitiesPerForceChart() {
  var interval = dojo.byId("entitiesPerForceTimeIntervalSelect").get("value");
  // [...] rest of your code
}