我正在使用jQuery 在Ajax上进行第一次破解.我将数据放到我的页面上,但是我在为Date数据类型返回的JSON数据方面遇到了一些麻烦.基本上,我得到的字符串看起来像这样:
/Date(1224043200000)/
Run Code Online (Sandbox Code Playgroud)
从全新的人到JSON - 如何将其格式化为短日期格式?这应该在jQuery代码中的某个地方处理吗?我试过使用jQuery.UI.datepicker插件$.datepicker.formatDate()没有任何成功.
仅供参考:以下是我提出的解决方案:
function getMismatch(id) {
$.getJSON("Main.aspx?Callback=GetMismatch",
{ MismatchId: id },
function (result) {
$("#AuthMerchId").text(result.AuthorizationMerchantId);
$("#SttlMerchId").text(result.SettlementMerchantId);
$("#CreateDate").text(formatJSONDate(Date(result.AppendDts)));
$("#ExpireDate").text(formatJSONDate(Date(result.ExpiresDts)));
$("#LastUpdate").text(formatJSONDate(Date(result.LastUpdateDts)));
$("#LastUpdatedBy").text(result.LastUpdateNt);
$("#ProcessIn").text(result.ProcessIn);
}
);
return false;
}
function formatJSONDate(jsonDate) {
var newDate = dateFormat(jsonDate, "mm/dd/yyyy");
return newDate;
}
Run Code Online (Sandbox Code Playgroud)
此解决方案从回调方法获取我的对象,并使用日期格式库正确显示页面上的日期.