它检索日期时间06/03/2014 12:00:00 AM和结束日期是31/03/2015 12:00:00 AM但在我的jquery警报消息中显示如下/ 9413044200000 /我不知道什么是a问题我需要在datepicker中设置最小日期和最长日期请帮助我。 。
我的JsonResult
public JsonResult GroupName(string tourname, string MatchType)
{
var sdate = entity.TblTournaments.FirstOrDefault(x => x.Torname == tourname && x.Recordstatus == 1).TourStartdate;
var edate = entity.TblTournaments.FirstOrDefault(x => x.Torname == tourname && x.Recordstatus == 1).TourEnddate;
var data = new { sdate, edate };
return Json(data, JsonRequestBehavior.AllowGet);
}
我的jquery是
$.post("/BindInventory/GroupName", { tourname: tname, MatchType: MatchType }, function (result) {
var startdate = result.sdate;
var enddate = result.edate;
alert(result.sdate);
$('#date').datepicker('option', 'minValue', new Date(startdate));
$('#date').datepicker('option', 'maxValue', new Date(enddate));
}, "json");
答案 0 :(得分:0)
您需要解析JSON - date with:
var date = new Date(parseInt(jsonDate.substr(6)));
来源:https://stackoverflow.com/a/2316066/1278667
修改强>: 在你的情况下:
$.post("/BindInventory/GroupName", { tourname: tname, MatchType: MatchType }, function (result) {
var startdate = new Date(parseInt(result.sdate.substr(6)));
var enddate = new Date(parseInt(result.edate.substr(6)));
$('#date').datepicker('option', 'minValue', startdate);
$('#date').datepicker('option', 'maxValue', enddate);
}, "json");