I know that are a lot of posts about consuming a WCF REST through JQuery/JSON, but I can\'t get it to work. I\'m currently stuck at a date parameter. Below is my C# method:<
I pulled out a lot of hair and shed plenty a tear over this but this worked. I modified the date formatting in your toMSJSON function. WCF accepts this format which I realised thanks to Rick Strahl.
Date.prototype.toMSJSON = function () {
var date = '/Date(' + this.getTime() + ')/'; //CHANGED LINE
return date;
};
You also need to convert the dates to UTC time or you get all kinds of funny stuff, so:
var dt = ...;
var dt1 = new Date(Date.UTC(dt.getFullYear(), dt.getMonth(), dt.getDate(), dt.getHours(), dt.getMinutes(), dt.getSeconds(), dt.getMilliseconds()));
var wcfDateStr = dt1.toMSJSON();
Hope this helps.