Cross Domain Batch Request fails

May 7, 2012 at 5:56 PM


I am using the simple XMLHttpRequest object to make an cross domain batch request with datajs 1.0.3. 

A preflight request is beeing sent to the server as expected:

OPTIONS http://localhost:64109/Services/ScheduleService.svc/$batch HTTP/1.1
Host: localhost:64109
Connection: keep-alive
Access-Control-Request-Method: POST
Origin: http://localhost:63718
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19
Access-Control-Request-Headers: origin, maxdataserviceversion, content-type, accept, dataserviceversion
Accept: */*
Referer: http://localhost:63718/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

The Server responds accordingly setting some headers as proposed for preflight requests (see:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/
Date: Mon, 07 May 2012 17:48:02 GMT
X-AspNet-Version: 4.0.30319
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Headers: Content-Type, Accept
Access-Control-Max-Age: 1728000
Cache-Control: private
Content-Length: 0
Connection: Close

I am getting an error message for the batch request saying "HTTP request failed".

What do I have to do? Does datajs do not handle the preflight response on it's own?


Would be happy to get some help on this. 

Best regards,


May 7, 2012 at 6:07 PM


the problem is solved:

One of the headers in the response of the server had to be extended by two more headernames:

Access-Control-Allow-Headers: Content-Type, Accept, MaxDataServiceVersion, DataServiceVersion


Best regards,


May 7, 2012 at 6:39 PM

Hi Sebastian,

    I'm glad you were able to solve your issue.  It is great that you are using datajs with CORS and I will love to get any feedback for your experience with it :).


Alex Trigo.