我刚用ajax不久,做了个超级简单的小程序,在html页面调用后台代码,总是出错!!以下是代码
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript" >
function ExecuteServerMethod()
{
var h= PageMethods.ReturnStringServerMethod();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" EnablePageMethods="true">
</asp:ScriptManager>
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
当前时间:<%DateTime.Now.ToString().Trim();%>
<input type="button" runat="server" id="sds" onclick="ExecuteServerMethod()" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
后台代码
[WebMethod]
public static string ReturnStringServerMethod()
{
return "jj";
}报的错误是:the server method ReturnStringServerMethod failed with the floowing error:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript" >
function ExecuteServerMethod()
{
var h= PageMethods.ReturnStringServerMethod();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" EnablePageMethods="true">
</asp:ScriptManager>
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
当前时间:<%DateTime.Now.ToString().Trim();%>
<input type="button" runat="server" id="sds" onclick="ExecuteServerMethod()" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
后台代码
[WebMethod]
public static string ReturnStringServerMethod()
{
return "jj";
}报的错误是:the server method ReturnStringServerMethod failed with the floowing error:
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货