0
有趣,因爲它聽起來返回JSON,我改變了我的數據表的數據到一個字符串,它看起來是 這樣的:Asp.Net MVC從字符串
{ blocks: [
{"fromAge" : "60","fromAmount" : "0","toAge" : "64","toAmount" : "65000","color" : "red","orderNo" : "2"},
{"fromAge" : "66","fromAmount" : "0","toAge" : "72","toAmount" : "12000","color" : "red","orderNo" : "4"},
{"fromAge" : "64","fromAmount" : "0","toAge" : "72","toAmount" : "34400","color" : "red","orderNo" : "1"},
{"fromAge" : "64","fromAmount" : "19500","toAge" : "66","toAmount" : "50750","color" : "red","orderNo" : "3"}
]}
與IDEEA說,「塊」是什麼像4個dicitionaries陣列,然後用這個動作我的字符串返回給查看:
public ActionResult ChartDetails()
{
return Json(GetJson(datatable));
}
的getJSON(數據表DT)是它返回字符串的方法中,並鑑於我得到這樣的:
"{ blocks: [{\"fromAge\" : \"60\",\"fromAmount\" : \"0\",\"toAge\" : \"64\",\"toAmount\" : \"65000\",\"color\" : \"Color [Orange]\",\"orderNo\" : \"2\"}, {\"fromAge\" : \"66\",\"fromAmount\" : \"0\",\"toAge\" : \"72\",\"toAmount\" : \"12000\",\"color\" : \"Color [Green]\",\"orderNo\" : \"4\"}, {\"fromAge\" : \"64\",\"fromAmount\" : \"0\",\"toAge\" : \"72\",\"toAmount\" : \"34400\",\"color\" : \"Color [Blue]\",\"orderNo\" : \"1\"}, {\"fromAge\" : \"64\",\"fromAmount\" : \"19500\",\"toAge\" : \"66\",\"toAmount\" : \"50750\",\"color\" : \"Color [Pink]\",\"orderNo\" : \"3\"}]}"
由於所有的「和」}「和」我無法用JQuery讀取JSON,有沒有一種方法可以在我的情況下返回一個正常編碼的字符串?
問題解決了! 謝謝!我對JavaScript和Json非常陌生...今天是漫長的一天搜索:) – andreiursan 2009-10-07 18:13:38