<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: XMLHttpRequest Cannot Load - Not Allowed By Access-Control-Allow-Origin in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/xmlhttprequest-cannot-load-not-allowed-by-access/m-p/708797#M65933</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;Now I know this is due to the lack of CORS support on that server and I can see this by the error message and in most cases it can be ignored, but this is stopping the function from being run.&lt;BR /&gt;&lt;BR /&gt;If I can the crafted URL and paste it into a browser, it executes fine. &lt;BR /&gt;&lt;BR /&gt;Any ideas on how one can query the Portal API without this happening?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Without CORS support, browsers won't let you do a cross-domain POST due to &lt;/SPAN&gt;&lt;A href="http://en.wikipedia.org/wiki/Same_origin_policy"&gt;same origin policy&lt;/A&gt;&lt;SPAN&gt;. Use a &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/ags_proxy.htm"&gt;proxy page&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Aug 2012 12:26:45 GMT</pubDate>
    <dc:creator>derekswingley1</dc:creator>
    <dc:date>2012-08-27T12:26:45Z</dc:date>
    <item>
      <title>XMLHttpRequest Cannot Load - Not Allowed By Access-Control-Allow-Origin</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/xmlhttprequest-cannot-load-not-allowed-by-access/m-p/708796#M65932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi There, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have an application that communicates to AGOL's Portal API to carry out a few tasks. One of these tasks is to check the membership of a group.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is a code snippet below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

function checkMembership() {

&amp;nbsp;&amp;nbsp;&amp;nbsp; var restService = "https://www.arcgis.com/sharing/community/groups/" + groupId + "/users";
&amp;nbsp;&amp;nbsp;&amp;nbsp; var restParameters = "?v=1&amp;amp;f=json&amp;amp;token=" + tokenInformation.token;

&amp;nbsp;&amp;nbsp;&amp;nbsp; $.ajax({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "type":"POST",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "url":restService + restParameters,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "dataType":"json",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; success:function (json) { 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; error:function (xhr, err) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; })
&amp;nbsp; }
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error been thrown in the console is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;XMLHttpRequest cannot load &lt;/SPAN&gt;&lt;A href="https://www.arcgis.com/sharing/community/groups/" rel="nofollow noopener noreferrer" target="_blank"&gt;https://www.arcgis.com/sharing/community/groups/&lt;/A&gt;&lt;SPAN&gt;[GROUP ID]/users?v=1&amp;amp;f=json&amp;amp;token=[TOKEN] Origin &lt;/SPAN&gt;&lt;A href="http://localhost" rel="nofollow noopener noreferrer" target="_blank"&gt;http://localhost&lt;/A&gt;&lt;SPAN&gt; is not allowed by Access-Control-Allow-Origin.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I know this is due to the lack of CORS support on that server and I can see this by the error message and in most cases it can be ignored, but this is stopping the function from being run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I can the crafted URL and paste it into a browser, it executes fine. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas on how one can query the Portal API without this happening?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:46:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/xmlhttprequest-cannot-load-not-allowed-by-access/m-p/708796#M65932</guid>
      <dc:creator>JithenSingh</dc:creator>
      <dc:date>2021-12-12T05:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: XMLHttpRequest Cannot Load - Not Allowed By Access-Control-Allow-Origin</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/xmlhttprequest-cannot-load-not-allowed-by-access/m-p/708797#M65933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;Now I know this is due to the lack of CORS support on that server and I can see this by the error message and in most cases it can be ignored, but this is stopping the function from being run.&lt;BR /&gt;&lt;BR /&gt;If I can the crafted URL and paste it into a browser, it executes fine. &lt;BR /&gt;&lt;BR /&gt;Any ideas on how one can query the Portal API without this happening?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Without CORS support, browsers won't let you do a cross-domain POST due to &lt;/SPAN&gt;&lt;A href="http://en.wikipedia.org/wiki/Same_origin_policy"&gt;same origin policy&lt;/A&gt;&lt;SPAN&gt;. Use a &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/ags_proxy.htm"&gt;proxy page&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2012 12:26:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/xmlhttprequest-cannot-load-not-allowed-by-access/m-p/708797#M65933</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2012-08-27T12:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: XMLHttpRequest Cannot Load - Not Allowed By Access-Control-Allow-Origin</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/xmlhttprequest-cannot-load-not-allowed-by-access/m-p/708798#M65934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Derek. Will give it a go.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2012 21:10:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/xmlhttprequest-cannot-load-not-allowed-by-access/m-p/708798#M65934</guid>
      <dc:creator>JithenSingh</dc:creator>
      <dc:date>2012-08-27T21:10:51Z</dc:date>
    </item>
  </channel>
</rss>

