我有这个g:formRemote
,它使用ajax提交表单。
<g:formRemote name="listAll" update="menuItemAJAX" url="[controller: 'superWaiter', action:'menuItem']" onSuccess="additionalContent()">
<a href="#" id="all" class="list-group-item" onclick="myFunction()">All</a>
</g:formRemote>
我不想使用按钮,因为它可以更轻松地设置链接样式。它不适用于
<script type="text/javascript">
function myFunction(){
$('#listAll').submit();
};
</script>
顺便说一句,表单的ID为
listAll
,因为它是从name
attr获取的
最佳答案
这是我几年前写的link to a blog post,其中包含您可以进行的每个Grails Ajax调用的示例,这是link to the code on GitHub。也有为Grails 2.x编写的更新版本。
关于javascript - 如何使用提交按钮免费提交AJAX表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22408830/