Dojo.request for iteminfo - return code 200 in Fiddler but 0 in the browser
<p>I use the same code for <code>dojo.request</code> as in <a href="https://stackoverflow.com/q/33781280/1801588">a previous project</a>, except for the URL address and the fact I'm calling service's <code>iteminfo</code> instead of layer's <code>addFeatures</code>. However, I always get the following error:</p>

<pre><code>Unable to load http://foobar.com/arcgis/rest/services/MapServer/info/iteminfo status: 0
</code></pre>

<p>I confirmed this in Firefox and IE. The status shown by Firebug or Visual Studio is always 0, even though the status shown in Fiddler is 200. It shows 0 also when I mess something up and get 401 in Fiddler.</p>

<p>So, here's my code:</p>

<pre><code>var promise = require('dojo/request').post(uri, {
    handleAs: "json",
    query: "f=pjson",        
    headers: {
        "X-Requested-With": null
    },
    //timeout: 60000,  //commenting this in and out changes nothing
    withCredentials: true
});

var res = promise.isResolved();
var rej = promise.isRejected();
var ful = promise.isFulfilled();
var can = promise.isCanceled();
var respres = promise.response.isResolved();
var resprej = promise.response.isRejected();
var respful = promise.response.isFulfilled();
var respcan = promise.response.isCanceled();

promise.response.then(
  //success
  function (response) {
    //something
  },
  //fail
  function (error) {
    //something different
  }
);
</code></pre>

<p>I want the output as a JSON, so I added the <code>query</code> option; without it, Fiddler shows the output as HTML instead. I found an <a href="https://stackoverflow.com/a/9038812/1801588">answer</a> indicating that the response may need time, but either it's not my case or something more complex than simple <code>timeout</code> option is needed.</p>

<p>All my test variables (<code>res</code>,<code>rej</code>...) hold <code>false</code>. So the request seems unresolved, unfulfilled etc. in the code, but Fiddler returns the response - I'm not skilled enough in these network arts to be able to draw conclusion from this, so I ask the question.</p>

<p>Also, I have a vague impression that some additional headers should be the solution. I've tried adding <code>accept</code> (nothing changed) and <code>content-type</code> (it went <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests" rel="nofollow noreferrer">pre-flight</a> and Fiddler reported status 401).</p>

<p>EDIT: the response header contains following security info:</p>

<pre><code>Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Origin: http://localhost:30322 //origin for now
Access-Control-Allow-Origin: *
</code></pre>