$.ajaxSetup({ converters: { '* text': window.String, 'text html': true, 'text json': parseDotNetJson, 'text xml': jQuery.parseXML } }); function parseDotNetJson(data) { return JSON.parse(data, function(key, value) { if (typeof value === 'string') { var a = /\/Date\((-?\d*)\)\//.exec(value); if (a) return new Date(+a[1]); } return value; }); }
I place this code in the root of a script file. I use this to convert dates parsed to JSON by ASP.Net MVC.
No comments:
Post a Comment