title: Access to XMLHttpRequest at '...' from origin 'http://localhost' has been blocked by CORS policy
body: <p><br>
  I'm trying to demo an api call with javascript to get Json result. Here is what I did:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
          &lt;script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"&gt;&lt;/script&gt;
      &lt;body&gt;
          &lt;div class="render-form"&gt;
              &lt;script&gt;
                  $(document).ready(function() {
                      $.ajax({
                          type: 'GET',
                          headers:{    
                              'Accept': 'application/json',
                              'Content-Type': 'application/json',
                              'Access-Control-Allow-Origin': '*' 
                          },
                          url: 'http://127.0.0.1:8080/activiti-rest/service/form/form-data?taskId=21159',
                          dataType: 'json',
                          success: function (data) {
                              alert(JSON.stringify(data));
                          }
                      });
                  })
              &lt;/script&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But when I run it, I got an error:</p>
  
  <blockquote>
    <p>Access to XMLHttpRequest at '<a href="http://127.0.0.1:8080/activiti-rest/service/form/form-data?taskId=21159" rel="noreferrer">http://127.0.0.1:8080/activiti-rest/service/form/form-data?taskId=21159</a>' from origin '<a href="http://localhost" rel="noreferrer">http://localhost</a>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.</p>
  </blockquote>
  
  <p>After searching many post in here, I added:</p>
  
  <pre><code>headers:{    
      'Accept': 'application/json',
      'Content-Type': 'application/json',
      'Access-Control-Allow-Origin': '*' 
  },
  </code></pre>
  
  <p>But it still not work with that error. How should I fix this?<br>
  Any reply would be very appreciate!<br>
  Thank you very much! &nbsp;</p>