Using the ArcGIS for JavaScript API 3.19, I'm submitting a job to the ExtractData geoprocessing service at:
https://analysis7.arcgis.com/arcgis/rest/services/tasks/GPServer/ExtractData/submitJob
The job is submitted and run successfully, and the output is created in my ArcGIS Online root folder.
However, I can't figure out how to get the response back from the server. When I submit the job, the JavaScript console reports 2 errors:
SEC7127: Redirect was blocked for CORS request.
SCRIPT7002: XMLHttpRequest: Network Error 0x800c0014, A redirection problem occurred.
This sort of makes sense to me, because the server issues a redirect to the job page. I can see that the server responds with a status of 303, and includes the URL to the job in the response. However, the code that I have to handle the response (see below) is never called.
<SPAN class="keyword token">var</SPAN> url <SPAN class="operator token">=</SPAN> _extractDataURL <SPAN class="operator token">+</SPAN>
<SPAN class="string token">"?inputLayers="</SPAN> <SPAN class="operator token">+</SPAN> inputLayers <SPAN class="operator token">+</SPAN>
<SPAN class="string token">"&extent="</SPAN> <SPAN class="operator token">+</SPAN> extent <SPAN class="operator token">+</SPAN>
<SPAN class="string token">"&clip="</SPAN> <SPAN class="operator token">+</SPAN> clip <SPAN class="operator token">+</SPAN>
<SPAN class="string token">"&dataFormat="</SPAN> <SPAN class="operator token">+</SPAN> dataFormat <SPAN class="operator token">+</SPAN>
<SPAN class="string token">"&outputName="</SPAN> <SPAN class="operator token">+</SPAN> outputName <SPAN class="operator token">+</SPAN>
<SPAN class="string token">"&context="</SPAN> <SPAN class="operator token">+</SPAN> context <SPAN class="operator token">+</SPAN>
<SPAN class="string token">"&f="</SPAN> <SPAN class="operator token">+</SPAN> f <SPAN class="operator token">+</SPAN>
<SPAN class="string token">"&token="</SPAN> <SPAN class="operator token">+</SPAN> IdentityManager<SPAN class="punctuation token">.</SPAN>credentials<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>token<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> xmlHTTPRequest <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">XMLHttpRequest</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
xmlHTTPRequest<SPAN class="punctuation token">.</SPAN>onreadystatechange <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>xmlHTTPRequest<SPAN class="punctuation token">.</SPAN>readyState <SPAN class="operator token">==</SPAN> <SPAN class="number token">4</SPAN> <SPAN class="operator token">&&</SPAN> xmlHTTPRequest<SPAN class="punctuation token">.</SPAN>status <SPAN class="operator token">==</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>responseText<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
xmlHTTPRequest<SPAN class="punctuation token">.</SPAN>onload <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>responseText<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
xmlHTTPRequest<SPAN class="punctuation token">.</SPAN><SPAN class="token function">open</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"GET"</SPAN><SPAN class="punctuation token">,</SPAN> url<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
xmlHTTPRequest<SPAN class="punctuation token">.</SPAN><SPAN class="token function">send</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>How can I configure things so that the redirect (the correct response) doesn't cause the CORS error, and so that I can handle the response and get the URL to the job?