FirstAjaxForFun.ashx代码:
public void ProcessRequest(HttpContext context) {
context.Response.ContentType = "text/plain";
System.Threading.Thread.Sleep(2000);
//测试客户端if (xhr.status == 200)的时候用
//int a = 0;
//int c = 1 / a;
//context.Response.Write("<h1>" + "Hello World!" +
// DateTime.Now.ToLocalTime().ToString() + "</h1>");
if (!string.IsNullOrEmpty(context.Request.Form["txtName"]))
{
//{'data':'who are you post'} 是Json格式的字符串
context.Response.Write("{'data':'who are you post'}");
}
else
{
context.Response.Write("{'data':'No,I am get'}");
}
} 作者: 聂玉林 时间: 2012-11-23 10:51