json序列化的问题

mengjun5200 mengjun5200 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
json.ashx:

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;
}
}




index.aspx:


<%@ 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>

...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
mengjun5200
JavaScript 87,984 成员 224,680 内容