The moose likes Groovy and the fly likes Ajax RemoteFunction Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Other Languages » Groovy
Reply Bookmark "Ajax RemoteFunction" Watch "Ajax RemoteFunction" New topic
Author

Ajax RemoteFunction

Jack Rackham
Greenhorn

Joined: Aug 03, 2011
Posts: 23
Hi all,

I have a page, and on this page I have a select box. I want that when I click on one of the choices in my select box, the selected element is send to a controller, that controller makes a GORM search, when returns it to a template which will be dynamically printed on the screen. Here is my code at the moment, actually I think the action is not even called.

Main page :


EmailController.groovy


_formSelectTemplate.gsp
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

actually I think the action is not even called.


Then you should do something to ensure that it is. Like breakpoints or log statements or println statements.

The only issue I see in your code is this...



Views are not prefixed with an underscore. Templates are, which is what you really need to be calling.



Technically, you should be geting a 404 from the server. I'd recommend a tool like Firebug if you're going to be trying to debug ajax / javascript stuff.


My Blog | DZone Articles
Jack Rackham
Greenhorn

Joined: Aug 03, 2011
Posts: 23
Yes I use Firebug and I've put a println when at the beginning of the action. Look once again ;)
And I've not seen any 404 with Firebug.
Jack Rackham
Greenhorn

Joined: Aug 03, 2011
Posts: 23
Sorry for yesterday, I was in a hurry before leaving work, I didn't even thank you ;)

I've fixed the code with template. And anything I choose, or template or view (and renaming the gsp as it must be), it doesn't work.

And why should I get a 404 ?

EDIT : As newby in grails I ask the question, should I put the g:select into a formRemote or another form, or does it work if I let it alone ?

EDIT 2 : Here is the HTML code on the select get with Firebug :



As you see, there is no js event on the select.
Jack Rackham
Greenhorn

Joined: Aug 03, 2011
Posts: 23
I fixed it. It's my fault, I've forgotten the comas, and I had to replace the double quotes by single ones.
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

Glad you figured it out. To answer your question about why you should have gotten a 404 (which you would have had you been hitting the controller) is because when you render a view grails goes and looks for a GSP. It would not have found one, so it would have returned a 404 to the browser.
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

BTW, while cross-posting is a perfectly fine thing to do in order to get some answers, it would be nice if you let us know (and probably let SO know as well) that you did so.

http://stackoverflow.com/questions/7804700/grails-remoteform-ajax-doesnt-work

BeForthrightWhenCrossPostingToOtherSites
Jack Rackham
Greenhorn

Joined: Aug 03, 2011
Posts: 23
Gregg Bolinger wrote:BTW, while cross-posting is a perfectly fine thing to do in order to get some answers, it would be nice if you let us know (and probably let SO know as well) that you did so.

http://stackoverflow.com/questions/7804700/grails-remoteform-ajax-doesnt-work

BeForthrightWhenCrossPostingToOtherSites


Yes that's me. I hadn't seen this (even though no one should ignore the law), I hadn't wondered about cross-posting before. So accept my apologizes if necessary.

ANd thanks for your answer about the 404 ;)
 
jQuery in Action, 2nd edition
 
subject: Ajax RemoteFunction
 
Threads others viewed
Upload a File Using jQuery
request.getAttribute returning null
Grails Application, remoteFunction with Effects
Where are the temporary files located? Need pointers for debugging failing Ajax call/rendering
[Grails] Add form elements with javascript
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture