json处理Javascript 和web服务器端的之间数据交换
那位大神给写个json处理Javascript 和web服务器端的之间数据交换简单实列啊。。。。 JSON JavaScript
[解决办法]
<head runat="server">
<title></title>
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
function getjson() {
$.getJSON("/ajax/_getjson.ashx", function (data) {
alert(data.haha[0].ha);
});
// $.ajax({
// type: 'post',
// dataType: 'json',
// contentType: "application/json; charset=utf-8",
// url: "/ajax/_getjson.ashx",
// success: function (data) {
//
// alert(data.haha[0].ha);
// },
// error: function (data) {
// alert("error" + data);
// }
// });
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="button" onclick="getjson();" />
</div>
</form>
</body>
</html>
public void ProcessRequest(HttpContext context)
{
//context.Response.ContentType = "text/plain";
context.Response.ContentType = "application/json";
context.Response.Write("{"result":"0","haha":[{"ha":"1"}]}");
}
public bool IsReusable
{
get
{
return false;
}
}