title: Error: No 'Access-Control-Allow-Origin' header is present on the requested resource
body: <p>I have two systems <code>helpdesk.ops.something.in</code> and <code>dev1.ops.something.in</code></p>
  
  <p>I have a file <code>fetchP.php</code> in helpdesk.ops whose code goes something like this:</p>
  
  <pre><code>&lt;?php
  header('Access-Control-Allow-Origin: *');
  &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      function someFunc(item) {
          $.ajax({method:"GET", 
          url:"http://dev1.ops.something.in/wallet/createurl.php?phone="+item, 
          success:function(response){
              console.log(response);
          }
          });
      };
  &lt;/script&gt;';
  &lt;?php
  echo '&lt;div id="callToWallet" class="sample-button" onclick="someFunc(911234567890);"&gt;&lt;a href="#"&gt; Click here&lt;/a&gt;&lt;/div&gt;';
  </code></pre>
  
  <p>which is doing a GET request to a file <code>createurl.php</code> present in the dev1.ops, which goes something like this:</p>
  
  <pre><code>&lt;?php
  header('Access-Control-Allow-Origin: *');?&gt;
  &lt;script&gt;response.addHeader("Access-Control-Allow-Origin", "*");&lt;/script&gt;
  &lt;?php 
  // the rest of the code
  ?&gt;
  </code></pre>
  
  <p>But on executing, the GET request is not successful, and I am getting error:</p>
  
  <p><code>XMLHttpRequest cannot load http://dev1.ops.something.in/wallet/createurl.php?phone=911234567890. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://helpdesk.ops.something.in' is therefore not allowed access. The response had HTTP status code 500.</code></p>
  
  <p>What am I missing?</p>