首先在A页面,进行$.ajax B页面
然后在B页面加载完毕后,将自己的数据提交到C
结果是,到了B页面,无法通过自身请求提交,也不会执行javascript
测试代码
页面A
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
$(function () {
$.ajax({
type: "POST",
url: "b.aspx",
data:
{
t: "game"
},
success: function (html) {
alert(html);
}
});
});
</script>
</div>
</form>
</body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
$(function () {
$.ajax({
type: "POST",
url: "b.aspx",
data:
{
t: "game"
},
success: function (html) {
alert(html);
}
});
});
</script>
</div>
</form>
</body>
页面B
<body onload="document.forms['order'].submit();">
<form id="order" name="order" accept="post" action="b.aspx">
<input type="text" id="t1" name="t1" value="" />
<div>
<script type="text/javascript">
alert("到了b了");
document.getElementById("t1").value = "3";
document.getElementById("form1").submit();
window.location.href = "c.aspx";
</script>
</div>
</form>
</body>
<form id="order" name="order" accept="post" action="b.aspx">
<input type="text" id="t1" name="t1" value="" />
<div>
<script type="text/javascript">
alert("到了b了");
document.getElementById("t1").value = "3";
document.getElementById("form1").submit();
window.location.href = "c.aspx";
</script>
</div>
</form>
</body>
解决方案
在A页面,通过一个表单提交到B
页面1
<body>
<form id="form1" runat="server">
<div>
<input type="button" name="name" value="提交测试" />
</div>
</form>
<form action="WebForm2.aspx" target="_blank" method="post">
<input type="hidden" name="h1" value="1" />
<input type="submit" name="h2" value="提交测试" />
</form>
</body>
<form id="form1" runat="server">
<div>
<input type="button" name="name" value="提交测试" />
</div>
</form>
<form action="WebForm2.aspx" target="_blank" method="post">
<input type="hidden" name="h1" value="1" />
<input type="submit" name="h2" value="提交测试" />
</form>
</body>
页面2
<body onload="document.forms['order'].submit();">
<form id="order" accept="post" action="WebForm3.aspx">
<div>
</div>
</form>
</body>
<form id="order" accept="post" action="WebForm3.aspx">
<div>
</div>
</form>
</body>
页面3
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>