title: How to download stream returned from WCF service and that WCF service called from jquery ajax call
body: <p>I am consuming WCF Service Methods from client side using JQuery. I want to save the stream data which is returned from WCF method at client side. Following WCF method is working fine in which I am using our own excelExport's method to create memory stream -</p>
  
  <pre><code>public System.IO.Stream TestExportToExcel()
      {
          using (_oxBowData = new Data.OxbowDataContext())
          {
              ExcelExport excelExport = new ExcelExport();
              List&lt;SheetData&gt; sheets = new List&lt;SheetData&gt;();
              sheets.Add(new SheetData()
              {
                  SheetName = "sheet1",
                  DataList = _oxBowData.GetLunchReportData(new DateTime(2013, 12, 24)).ToList&lt;object&gt;()
              });
              using (MemoryStream xlsstream = excelExport.ExportToExcelToStream(sheets))
              {
                  xlsstream.Position = 0L;
                  return xlsstream;
              }
          }
      }
  </code></pre>
  
  <p>Service Contract:</p>
  
  <pre><code>[OperationContract]
  [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json,
  BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "TestExportToExcel")]
  System.IO.Stream TestExportToExcel();
  </code></pre>
  
  <p>Following is what I am using at Client side but it just returning me error-</p>
  
  <pre><code>$.ajax({
                  type: "GET",
                  url: u + "/Terminal/ManagementService.svc/TestExportToExcel",
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  processData: false,
                  success: function (data) {
                      alert(JSON.stringify(data));
                  },
                  error: function (data) {
                      alert(JSON.stringify(data));
                  }
              });
  </code></pre>
  
  <p>When I call this client side ajax call it returns error. Can anybody help?</p>