title: Send JQuery JSON to WCF REST using date
body: <p>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:</p>
  
  <pre><code>[OperationContract]
  [WebInvoke]
  [TransactionFlow(TransactionFlowOption.Allowed)]
  string GoodRegister(DateTime pDtTimeStampTransac, Int32 pIDResource, Decimal pQty, enQtyLogType pQtyGoodLogType);
  </code></pre>
  
  <p>Below is my JavaScript code:</p>
  
  <pre><code>/// &lt;reference path="../Scripts/jquery-1.4.1-vsdoc.js" /&gt;
  /// &lt;reference path="json.js" /&gt;
  
  Date.prototype.toMSJSON = function () {
    var date = '\\\/Date(' + this.getTime() + ')\\\/';
    return date;
  };
  
  function botaoclick() {
    var date = new Date().toMSJSON();
    var datavar = {
      'pDtTimeStampTransac': date,
      'pIDResource': 1,
      'pQty': 1
    };
    $.ajax(
    {
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "http://desk01:9876/ShopFloorService/script/GoodRegister",
      dataType: "json",
      data: JSON.stringify(datavar),
      //data: '{"pDtTimeStampTransac":date, "pIDResource":"teste", "pQty":"3"}',
      error: jqueryError,
      success: function (msg) {
        alert("back");
        var divForResult = document.getElementById("test");
        divForResult.innerHTML = "Result: &lt;b&gt;" + msg.d + "&lt;/b&gt;";
      }
    }
    )
  }
  
  function jqueryError(request, status, error) {
    alert(request.responseText + " " + status + " " + error);
  }
  </code></pre>
  
  <p>My first problem is that I keep getting a date serialization error:</p>
  
  <pre><code>{"ExceptionDetail":{"HelpLink":null,"InnerException":{"HelpLink":null,"InnerException":{"HelpLink":null,"InnerException":null,"Message":"DateTime content '\\\/Date(1292616078638)\\\/' does not start with '\\\/Date(' and end with ')\\\/' as required for JSON.","StackTrace":"   at System.Runtime.Serialization.Json.JsonReaderDelegator.ParseJsonDate(String originalDateTimeValue)\u000d\u000a   at 
  </code></pre>
  
  <p>It says it doesn't start/end the way it's starting and ending.</p>
  
  <p>My second question is: Will I have to get ride of the enumerator, or is there a way to send it?</p>