I am seeing something fishy there
var result = new Date(+dateString.replace(/\/Date\((-?\d+)\)\//gi, "$1"));
var result = new Date(parseInt(dateString.replace('/Date(', '')));
- you are making two variables named result within the same closure, is it intentional?
- what does result.format do? since result is a Date object I wouldn't assume that it would change the original type from Date to string.
Maybe
var s = result.format("dd-MM-yyyy");
return s;
is what you really want to do?
you can do this after the ajax complete, this will save you tons of trouble having to parse the Date(xxxxx) thing over and over again
data = data.replace(/\"\\\/Date\((-?\d+)\)\\\/\"/g, '$1')
this will convert "Date(xxxx)" to xxxx and then you can just call new Date(xxxx) to make new Date object.