87,997
社区成员




using System;
using System.Web;
using Newtonsoft.Json;
public class json : IHttpHandler {
public void ProcessRequest (HttpContext context) {
com c = new com(1,"张下滑",34,"男");
string cjson = JavaScriptConvert.SerializeObject(c);
context.Response.Write(cjson);
}
public bool IsReusable {
get {
return false;
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="jquery-1[1].3.2.js"></script>
<script type="text/javascript">
$(function() { $getJSON("json.ashx", function(json) { alert("uid="+json.id+";name="+json.name+";age="+age+";sex="+sex) }); })
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>