52,797
社区成员
发帖
与我相关
我的任务
分享
protected void check()
{
Response.Write("AJAX Call Server Method of check()");
}
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender,EventArgs e)
{
if(Request.Form["call"]=="1"){check();Response.End();}
}
protected string check()
{
Response.Write("AJAX Call Server Method of check()");
}
</script>
<script>
if(window.ActiveXobject)xmlHttp=new ActiveXObject("Microsoft.xmlhttp");
else xmlHttp=new XMLHttpRequest();
xmlHttp.open("POST", "test.aspx",true);
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)alert(xmlHttp.responseText);
else alert("发生错误!");
}
}
xmlHttp.send("call=1");
</script>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>