Ajax
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange =callback1;
xmlHttp.open("post", "/ashx/myzhuye/Detail.ashx?methodName=GetAllComment", true);
xmlHttp.send("methodName = GetAllComment&str1=str1&str2=str2");
function callback1() {
if (xmlHttp.readyState == 4)
if (xmlHttp.status == 200) {
var data = xmlHttp.responseText;
data = eval(data);
$.each(data,
function(i, v) {
alert(v);
});
}
}
private void GetAllComment(HttpContext context)
{
string methodName = context.Request.Params["methodName"];
string str1 = context.Request.Form["str1"];
string str2 = context.Request["str2"];
List<string> comments = new List<string>();
comments.Add(methodName);
comments.Add(str1);
comments.Add(str2);
string commentsJson = new JavaScriptSerializer().Serialize(comments);
context.Response.Write(commentsJson);