title: No 'Access-Control-Allow-Origin' header is present. Origin is therefore not allowed access
body: <p>EDIT: No JSONP! Yes i know CORS is handled by the server and Yes the server does support it. The issue is on my side.</p>
  
  <p>I am trying to use MediaWiki API from the browser. I am sending a GET request through XMLHttpRequest but due to CORS issues it's just not working. I am getting the following message from my browser after it receives the response:</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="https://en.wikipedia.org/w/api.php?format=json&amp;action=query&amp;list=search&amp;srsearch=Oculus&amp;utf8" rel="noreferrer">https://en.wikipedia.org/w/api.php?format=json&amp;action=query&amp;list=search&amp;srsearch=Oculus&amp;utf8</a>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://127.0.0.1:8000" rel="noreferrer">http://127.0.0.1:8000</a>' is therefore not allowed access.</p>
  </blockquote>
  
  <p>I understand why i am getting this issue but i do not know how can i solve it from the browser/JavaScript side.</p>
  
  <p>Code:</p>
  
  <pre><code>xmlhttp.open("GET","https://en.wikipedia.org/w/api.php?format=json&amp;action=query&amp;list=search&amp;srsearch=" + subreddit + "&amp;utf8",true);
  xmlhttp.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
  xmlhttp.send();
  </code></pre>
  
  <p>Some of the things i've tried:</p>
  
  <pre><code>xmlhttp.setRequestHeader('Access-Control-Allow-Origin', 'http://localhost');
  xmlhttp.setRequestHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
  xmlhttp.setRequestHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
  xmlhttp.setRequestHeader('Access-Control-Allow-Credentials', true)
  xmlhttp.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
  </code></pre>
  
  <p>and setting the parameter origin in the url or as setRequestHeader which returned a invalid/bad Origin, denied.</p>