<div id="content">
<input id="btnShow" type="button" value="button" />
</div>
<script type="text/javascript">
$("#btnShow").click(function () {
$.ajax({
url: "handle.ashx",
asyn: true,
data: { LoginName: "lm", pwd: "mm" },
dataType: "json", success: function (msg) {
//alert(msg.name);
$("#btnShow").after("<h1>" + msg.name + "</h1>");
},
error: function (data) { alert(data);
alert(data.error);
}
});
});
</script>

后台:

context.Response.ContentType = "application/json";
//context.Response.ContentType = "text/plain";
string name = context.Request["LoginName"].ToString();
string age = context.Request["pwd"].ToString();
string json = "{\"name\":\"张三\"}"; context.Response.Write(json);
//context.Response.Write("老王");
05-08 08:22