0
從json檢索代碼。從c#linq對象檢索數據到json到html
C#代碼: -
var collection = getsortcat.Select(x => new
{
idterm = x.IDTerm,
mvo = x.MVO,
pic = x.Pic,
said = x.SAid,
termactive = x.TermActive,
vid = x.Vid,
fvo = x.FVO,
eterm = x.ETerm,
edef = x.EDef,
buse = x.BUse,
bterm = x.BTerm,
idcat = x.TermCat,
items = x.TermCategory1.IDCat,
catname = x.TermCategory1.TermCategory1
});
JavaScriptSerializer jss = new JavaScriptSerializer();
string output = jss.Serialize(collection);
return Json(output, JsonRequestBehavior.AllowGet);
的JavaScript代碼: -
success: function (e) {
var txt = "'{ data :" + e + "}'";
var obj = eval("(" + txt + ")");
$('#pdata').append(obj.data[0]);
},
沒有得到輸出。請給我解決方案如何檢索數據從C#linq對象到JSON到HTML?
任何理由downvote? –
我爲你+1了。看起來對我來說是正確的答案。 –
謝謝達丁先生。非常感謝。 –