asp.net中用jquery.ajaxform提交多个form当中的一个,ajaxform失效
为什么ajaxform都不好用了?连beforeSubmit都不能执行,不知道为什么,请大侠们指教
//----------------------------------------------------
WebForm1.aspx
代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.form.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#Div2").find("form").submit(function () {
$(this).ajaxForm({
url: "/Action/Handler1.ashx",
data: { id: 2 },
dataType: 'json',
beforeSubmit: function () {
window.open("/Action/Handler1.ashx?id=2");
//alert("Div2");
},
success: function (data) {
alert(data.id);
}
});
return false;
});
$("#Div3").find("form").submit(function () {
$(this).ajaxForm({
url: "/Action/Handler1.ashx",
data: { id: 3 },
dataType: 'json',
beforeSubmit: function () {
window.open("/Action/Handler1.ashx?id=3");
//alert("Div3");
},
success: function (data) {
alert(data.id);
}
});
return false;
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="Div2">
<form action="/Action/Handler1.ashx">
<textarea name="content2" id="content2" cols="50" rows="10">
</textarea>
<input type="submit" value="提交" />
</form>
</div>
</form>
<div id="Div3">
<form action="/Action/Handler1.ashx">
<textarea name="content3" id="Textarea3" cols="50" rows="10">
</textarea>
<input type="submit" value="提交" />
</form>
</div>
</body>
</html>
//----------------------------------------------------
Handler1.ashx代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication1.Action
{
/// <summary>