如果:
public ContentResult GetPaper(string testId)
{
return ControllProctector.Do1(() =>
{
var result = new UserPaperBll().GetTestPaper(testId, NativeHelper.LoginUser2.Id, NativeHelper.LoginUser2.OrganizationId);
return new ContentResult
{
Content = new JavaScriptSerializer { MaxJsonLength = int.MaxValue }.Serialize(result),
ContentType = "application/json"
};
});
}
我们会得到一些不正确的空值。需要去掉 ContentType = "application/json" 该行,然后前台将字符串转为 JSON 对象即可。
success: function (data) {
data = JSON.parse(data);