I noticed something when I was attempting to use remoteField ajax tag in grails. When I enter an ampersand (&), that value is not recognized in my controller when obtaining the parameter value.
Example: I will type Cat & Dog
What I see: Cat
How can I avoid this? Is this a known bug? I couldn’t find anything online about this.
Edit
I’m pretty sure this is due to url encoding and parameters, since an ampersand is usually a parameter delimiter. Just not sure how to get around this.
<g:remoteField action="getName" update="testDiv" paramName="search" name="nameSearchResults" value="" />
Controller:
def getName() {
println "Search result = " + params.search
//When typing "Cat & Dog" I get:
//Search result = C
//Search result = Ca
//Search result = Cat
//Search result = Cat
//Search result = Cat
}
Have you tried URL encoding the text in your
remoteField?I would recommend adding a
beforeproperty with JavaScript to URL encode the input:You will then have to decode it in the controller.