Tag: jsonresult

当本地机器和服务器在不同的时区时,Json返回不同的日期

我在json日期解析中遇到了一个奇怪的问题。 我使用以下内容来解析json日期: dateFormat(new Date(parseInt(user.RegDate.substr(6))), “mm/dd/yyyy”) 当我的本地计算机(客户端)与服务器时区位于不同的时区时,它会在我尝试检索用户的注册日期时返回不同的日期。 例如: SQL中的注册日期: 2010-07-22 19:00:00.000 当我在IST时区的本地机器中调试时,返回的JsonResult的日期是: /Date(1279805400000)/ Thu Jul 22 19:00:00 UTC+0530 2010 当我从EST时区的已部署服务器访问它时,相同的数据,JsonResult返回的日期是: /Date(1279843200000)/ Fri Jul 23 05:30:00 UTC+0530 2010 当我将本地机器更改为EST时区时,这完美(返回相同日期 – 7月22日星期四)。 我在这里错过了吗? 请建议 服务器代码是[编辑]: public JsonResult GetregisteredUsersJSON() { var usersList = this.GetregisteredUsers() return Json(usersList, JsonRequestBehavior.AllowGet); } private List GetregisteredUsers() { return (from u in _context.mu_Users orderby u.Reg_Date […]

用jquery获取json对象

$.getJSON(“/”, function(data) { var items = []; $.each(data, function(key, val) { items.push(val); }); }); [Authorize] [OutputCache(Duration = 0, VaryByParam = “None”)] public JsonResult myUrl() { var list = _repository.GetAll(); var items = list.Select(c => c.Name).ToList(); return Json(items, JsonRequestBehavior.AllowGet); } 我在服务器端创建一个列表(字符串名称列表)并返回一个JsonResult。 我正在尝试使用jquery在客户端获取列表,以便我可以检查它是否包含特定项目。 上面似乎没有用……有什么建议吗?

字符串的长度超过maxJsonLength属性上设置的值。 在MVC3中

MVC3(.cshtml文件) $.getJSON(URL, Data, function (data) { document.getElementById(‘divDisplayMap’).innerHTML = data; if (data != null) { $(‘#myTablesId’).show(); tdOnclickEvent(); } else { $(‘#myTablesId’).hide(); } }).error(function (xhr, ajaxOptions, thrownError) { debugger; }); 在服务器端 public JsonResult ZoneType_SelectedState(int x_Id, int y_Id) { JsonResult result = new JsonResult(); result.Data = “LongString”;//Longstring with the length mention below return Json(result.Data,”application/json”, JsonRequestBehavior.AllowGet); } 从服务器端我传递的字符串长度为1194812并且超过了。 但我得到的错误说 […]

排序不使用Json Result给出编码输出

我正在使用Json Result来显示一个表,当我显示结果时它工作正常。 现在我想为它添加一个排序function,所以我使用了canSort:true属性。 但是现在当我点击表格的标题以进行排序时,我在浏览器中得到了下面编码的字符串,它似乎也被排序了,但是对它进行了某种编码,如下所示。 {“Data”:”\u003ctable class=\”paramCustomDataTable\”\u003e\u003cthead\u003e\u003ctr class=\”customHead\”\u003e\u003cth scope=\”col\”\u003e\u003ca href=\”/Parameters/CustomData?id=7&sort=Name&sortdir=ASC\”\u003eName\u003c/a\u003e\u003c/th\u003e\u003cth scope=\”col\”\u003e\u003ca href=\”/Parameters/CustomData?id=7&sort=Value&sortdir=DESC\”\u003eDataValue\u003c/a\u003e\u003c/th\u003e\u003cth scope=\”col\”\u003eDelete\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd\u003eNewdata\u003c/td\u003e\u003ctd\u003e123456\u003c/td\u003e\u003ctd\u003e\u003ca href=\u0027delete/5\u0027\u003eDelete\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e”} 我知道下面的代码可能存在一些不一致之处,因为我必须删除版权问题的实际列。 C# code [CacheControl(HttpCacheability.NoCache), AcceptVerbs(HttpVerbs.Get)] public JsonResult GetMyData(int id) { var result = _myRepository.GetmyDataWithId(id).ToList(); var grid = new WebGrid(result, rowsPerPage: 5, canSort:true); var htmlString = grid.GetHtml( columns: grid.Columns( grid.Column(“Name”, “Name”), grid.Column(“Value”, “DataValue”), )); return Json(new { Data = htmlString.ToHtmlString() } , JsonRequestBehavior.AllowGet); […]