我有一個類ASP.NET MVC 3解析JSON對象和顯示數據
public class ConversionResultModel
{
public string ProcessId { get; set; }
public bool Result { get; set; }
public string Message { get; set; }
}
發送它使用JSON
public ActionResult UploadFile(IEnumerable<HttpPostedFileBase> clientUpload)
{
string destinationPath = "";
JsonResult result = null;
var fileModel = new ConversionResultModel();
fileModel.ProcessId = "4558-95559-554";
fileModel.Result = true;
fileModel.Message = "test.pdf";
result = Json(new { fileModel }, "text/plain");
return result;
}
如何使用JS或在客戶端解析這樣的JSON對象,以查看jQuery和讀取值?
我曾嘗試用代碼來解析JSON對象之下,但得到了一個未定義錯誤警報
var obj = $.parseJSON(e.response);
alert(e.obj);
我收到JSON對象,這樣
{"fileModel":{"ProcessId":"4558-95559-554","Result":true,"Message":null,"SourceFile":null,"ConvertedFileName":"test.pdf","ConvertedFileSize":1233444,"DownloadUrl":"http://localhost:2008/download?path=4558-95559-554","DeleteUrl":"http://localhost:2008/download?path=4558-95559-554"}}
我試圖用$ .parseJSON(e.response)解析,但它不起作用。 – Tomas 2012-02-29 12:24:51
它做了什麼或不做什麼?有沒有錯誤? – senfo 2012-02-29 12:26:43