日期:2014-05-16 浏览次数:20823 次
<%@ Page Language="C#" EnableViewState="false" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <script src="jquery-1.7.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $.ajax({ type: "POST", contentType: "application/json", url: "b.aspx/select",/* 对应后台的方法 */ data: "{time:'传入参数1',grogid:'传入参数2'}", dataType: 'json', success: function (list) { jsonData = jQuery.parseJSON(list.d); var t = "<table border='1'>"; $(jsonData).each(function (i, item) { t += "<tr>"; t += "<td>" + item.Name + "</td>"; t += "<td>" + item.Url + "</td>"; t += "</tr>"; }); t += "</table>"; $("#div2").html(t); }, error: function (err) { alert(err.responseText) } }); </script> </head> <script runat="server"> //定义例子实体类 // <summary> /// 类对象需要标记为DataContractAttribute /// </summary> [System.Runtime.Serialization.DataContract] public class MengxianHui { //成员需要标记为 DataMember [System.Runtime.Serialization.DataMember] public string Name { set; get; } [System.Runtime.Serialization.DataMember] public string Url { set; get; } } public static string ObjectToJson(object obj) { System.Runtime.Serialization.Json.D