我如何使用锚标签来提交一个表单与jQuery [英] How can I use an anchor tag to submit a form with jquery
本文介绍了我如何使用锚标签来提交一个表单与jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用下面的锚来向jQuery提交一个带Spring的表单。这是怎么完成的?
I want to use the following anchor to submit a form with jquery to Spring. How is this done?
<a target="" title="" class="" href="">Save</a>
我试过了,requestNew是我的表单:
I've tried this, where requestNew is my form:
$(document).ready(function(){
$("a").click(function(){
$("#requestNew").submit(function(){
$.post("../acctRequests", $("#requestNew").serialize());
});
});
});
它似乎没有去任何地方。
It doesn't seem to go anywhere.
推荐答案
您正在添加一个新的事件处理程序;您只需触发现有的功能即可:
You are adding a new event handler; all you need to do is trigger the existing ones, and the browser's native functionality:
$(document).ready(function(){
$("a").click(function(){
$("#requestNew").submit();
});
});
这篇关于我如何使用锚标签来提交一个表单与jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文