Pass Javascript Variable into createlink method call Grails

前端 未结 1 871
说谎
说谎 2021-01-12 15:58
var search= document.getElementById(\'appMenu\').value 
document.location.href= \'${createLink(controller: \'application\' , action:\'ajaxAppSearch\',   params: [\'q         


        
相关标签:
1条回答
  • 2021-01-12 16:50

    Grails (controllers, GSP and tags, etc) are working on server side. JavaScript on client side. And this link is prepared before sending data to browser, and before JavaScript can pass its variable into GSP tag.

    But you can prepare base link on server side, and add extra parameter on client side, by using javascript, like:

    var search= document.getElementById('appMenu').value;
    document.location.href= '${createLink(controller: 'application' , action:'ajaxAppSearch')}?query=' + escape(search);
    
    0 讨论(0)
提交回复
热议问题