日期:2014-05-16 浏览次数:20469 次
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>无标题页</title> <script type="text/javascript" src="prototype.js"></script> <script type="text/javascript"> function login() { new Ajax.Request( 'p2.aspx', { method: 'post', postBody: $('logform').serialize(), onSuccess: function( transport ) { alert(1); } } ); } </script> </head> <body> <form id="logform"> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGRs+GwJVuBVm9dJahyu9YPtnVNZBw==" /> <input type="button" onclick="login()" value="Login" /> </form> </body> </html>
<%@ Page Language="C#" %> <script type="text/javascript" src="prototype.js"></script> <script type="text/javascript"> function test(){ new Ajax.Request( 'p2.aspx', { method: 'post', postBody: $('logform').serialize(), onSuccess: function( transport ) { alert(1); } }); return false; } </script> <form id="Form1" runat="server"> <input id="bt001" type="button" value="Click" onclick="test();" /> </form>
------解决方案--------------------
我测试没有问题.
<%@ Page Language="C#" %> <script type="text/javascript" src="prototype-1.6.0.2.js"></script> <script type="text/javascript"> function test(){ new Ajax.Request('p2.aspx', { method:'post', postBody:'test1=1&test2=2', onSuccess:function(transport){ alert('test'); } }); return false; } </script> <form id="Form1" runat="server"> <input id="bt001" type="button" value="test" onclick="test();" /> </form>