-Edited -
您好,
我有一个包含两个表单的页面,我想使用post方法只发送第二个表单。
表格有一个有效的功能,可以检查有效的日期,电子邮件等。
我想在不离开页面的情况下发送第二个表单,只发送第二个表单。据我所知,它可用于AJAX,但我不确定如何执行它。
以下是代码
的示例客户端
<body>
<div> ....
<form id='f1'>....</form>
<script> //validation functions, at the end of the main validation function there is a //code that submits the second form , the one i intend to send.
</script>
<form id='f2' action='http://mysite/goToMyHandler.cs...>
...some input controls...
<input type='button' value='send' onclick='executeValidation();'>
</form>
</body>
服务器端
myHandler.cs:
...从
保存数据Response.Write('Form has been successfully sent');
由于
答案 0 :(得分:1)
使用jQuery和serializeObject。
这就是你要做的:
$.post($('#myform').attr('action'),$('#myform').serializeObject(),function(r){alert('successfully did it');});