<head>
<script type="text/javascript">
function miFuncion(inputText){
$.ajax({
url:"${request.contextPath}/Post/guardarComentario",
dataType: 'script',
type:'GET',
data: {
inputText: inputText,
val: $('#'+inputText).attr("value"),
},
//data: { ListID: '1', ItemName: 'test' },
success: function(data) {
//alert(data);
},
error: function(request, status, error) {
},
complete: function() {
//alert(data);
}
});
}
</script>
</head>
<body>
<input type="text" id="comentario" name="comentario"/>
<input type="button" onclick="miFuncion('comentario');" value="Enviar Comentario">
...
</body>
En el controlador
class Post {
static allowedMethods = [save: "POST", update: "POST", delete: "POST", list: "GET"]
def index() {
redirect(action: "list")
}
def guardarComentario() {
def user = User.get(session.user_id)
def val=params.val
switch(params.inputText){
case "comentario":
...
break;
...
}
}
}
No hay comentarios:
Publicar un comentario