Hello!
I wanted to do some Ajax with Grails. How can I change the below code in order to directly read out some information from the xml:
Code:def listXml ={ def books = Book.list(params) render(contentType:"text/xml"){ booklist{ for(b in books){ book(id:b.id){ title(b.title) author(b.author) } } } } } def showBooks = { render(template:'results', model: [value: params.value, books: books]) } search.gsp <html> <head> <meta name="layout" content="main" /> <title>Books Find</title> <g:javascript library="scriptaculous" /> </head> <body> <h2>Ajax Search</h2> <g:formRemote name="showBooks" url="[controller:'book',action:'showBooks']" update="[success:'results'" > <input type='text' name='value' value="${value}" /> <g:submitButton name="search" value="Search" /> </g:formRemote> Results: <div id="results"> </div> </body> </html> _result.gsp <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Sample title</title> </head> <body> <h1>Results</h1> <ol> <g:each var="book" in="${books}"> <li>${book?.author} <g:if test="${book.title}">- </g:if> ${book?.title} </li> </g:each> </ol> </body> </html>


Reply With Quote