Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/432.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript remotefunction上的参数不适用于grails 2.3.4_Javascript_Ajax_Grails - Fatal编程技术网

Javascript remotefunction上的参数不适用于grails 2.3.4

Javascript remotefunction上的参数不适用于grails 2.3.4,javascript,ajax,grails,Javascript,Ajax,Grails,我正在使用grails 2.3.4,根据grails文档,有和${remoteFunction}。我试图将值从参数发送到控制器,但返回空值。请帮助代码是: 普惠制页面代码为: <div id="test"></div> <input type="text" name="myname" id="myname"> <input type="button" name="view" value="view" onclick="myFunction()"&

我正在使用grails 2.3.4,根据grails文档,有
${remoteFunction}
。我试图将值从参数发送到控制器,但返回空值。请帮助代码是: 普惠制页面代码为:

<div id="test"></div>
    <input type="text" name="myname" id="myname">
<input type="button" name="view" value="view" onclick="myFunction()">
输出为:

test
params value is null
[action:testreport, format:null, controller:test]

你把事情搞砸了。渲染视图时在服务器端执行。当浏览器在客户端执行Javascript时,Javascript变量
name
将有一个值。您的代码中有一个输入错误。而不是

<g:remoteFunction controller="test" action="testreport" update="test" params="{n:name}"></g:remoteFunction>

使用


如果要提交多个参数,请使用

<g:remoteFunction controller="test" action="testreport" update="test" params='\'n=\' + name&paramName=\' + varName\''></g:remoteFunction>

你把事情搞砸了。渲染视图时在服务器端执行。当浏览器在客户端执行Javascript时,Javascript变量
name
将有一个值。您的代码中有一个输入错误。而不是

<g:remoteFunction controller="test" action="testreport" update="test" params="{n:name}"></g:remoteFunction>

使用


如果要提交多个参数,请使用

<g:remoteFunction controller="test" action="testreport" update="test" params='\'n=\' + name&paramName=\' + varName\''></g:remoteFunction>

我在gsp中以多种方式使用了g:remoteFunction-您可以使用:

    <button id=boxbtn onclick="<g:remoteFunction controller="Controller"   
action="action"   params="${[id:inputid, sortby:sortby, order:order, s:s,
  userchoice:'yes', viewtype:'na', offset:offset, max:max]}" update="siteContent"  />">

更新 尝试将此函数用作myFunction,而不是上面的函数

function myFunction(){
        var name = document.getElementById('myname');        
        <g:remoteFunction controller="test" action="testreport" update="test" params="${[n:name]}"></g:remoteFunction>

    }
函数myFunction(){
var name=document.getElementById('myname');
}

我在gsp中以多种方式使用了g:remoteFunction-您可以使用:

    <button id=boxbtn onclick="<g:remoteFunction controller="Controller"   
action="action"   params="${[id:inputid, sortby:sortby, order:order, s:s,
  userchoice:'yes', viewtype:'na', offset:offset, max:max]}" update="siteContent"  />">

更新 尝试将此函数用作myFunction,而不是上面的函数

function myFunction(){
        var name = document.getElementById('myname');        
        <g:remoteFunction controller="test" action="testreport" update="test" params="${[n:name]}"></g:remoteFunction>

    }
函数myFunction(){
var name=document.getElementById('myname');
}

对于传递一个参数,上述解决方案效果良好。如果我们想从另一个类似定义的变量传递第二个参数:var name=$(“#myname2”).val();,该怎么办。那么params:将如何更改?我已经尝试过了,但它显示了以下错误:org.codehaus.groovy.grails.web.taglib.exceptions.grailstageexception属性值必须被引用(controller=“test”action=“testreport”update=“test”params='\'n=\'+name')。对于传递一个参数,上述解决方案效果良好。如果我们想从另一个类似定义的变量传递第二个参数:var name=$(“#myname2”).val();,该怎么办。那么params:将如何更改?我已经尝试过了,但它显示了以下错误:org.codehaus.groovy.grails.web.taglib.exceptions.grailstageexception属性值必须被引用(controller=“test”action=“testreport”update=“test”params='\'n=\'+name')。这还显示null.test params值为null[action:testreport,format:null,controller:test]这是因为它不是远程函数,而是您向其传递值的java脚本…..这也显示了null.test参数值为null[action:testreport,format:null,controller:test],这是因为它不是远程函数,而是您向其传递值的java脚本。。。。。