Ajax não atualizar div
25/10/2015 02:41
class FeatureController {?
def scaffold = true
def featureService
def random() {
def randomFeature = featureService.getRandomFeature()
[feature: randomFeature]
}
def ajaxRandom() {
def randomFeature = featureService.getRandomFeature()
// render {
// q(randomFeature.name)
// p(randomFeature.description)
// }
render "<q>${randomFeature.name}</q>" +
"<p>${randomFeature.description}</p>"
}
}
?<html> <head>
<head>
<title>Random Quote</title>
<g:javascript library="jquery" />
</head>
<body>
<ul id="menu">
<li>
<g:remoteLink action="ajaxRandom" update="quote">
Next Quote
</g:remoteLink>
</li>
<li>
<g:link action="index">
Admin
</g:link>
</li>
</ul>
<div id="quote">
<q>${feature.name}</q>
<p>${feature.description}</p>
</div>
</body>
</html>
Entretanto, a div QUOTE não é atualizada quando o se clica no link da tag do RemoteLink. Simplemente, navega para a página ajaxRandom.
?<html> <head>
<title>QOTD » <g:layoutTitle/></title>
<g:external dir="css" file="main.css"/>
<g:layoutHead/>
<r:layoutResources />
</head>
<body>
<div id="header">
<g:img dir="images" file="apple-touch-icon.png" alt="logo"/>
</div>
<g:layoutBody/>
</body>
</html>
Para se registrar, clique aqui.