title: XMLHttpRequest cannot load *...* Origin : * is not allowed by Access-Control-Allow-Origin
body: <p>I am trying to use extjs store to talk to a Jersey rest Java application (running at tomcat) that returns a Json. 
  And I am trying to use Json to print to a grid component.
  This is my store code.</p>
  
  <pre><code>Ext.define('WSC.store.Users', {
  extend: 'Ext.data.Store',
  fields: ['period','tot_units', 'tot_selling_price'],
  model: 'WSC.model.User',
  proxy: {
      type: 'rest',
      url : 'http://localhost:8080/mondrianCube/services/query/querygoeshere/json',
      reader: {
          type: 'json',
          root: 'table'
      }
  },
  autoLoad: true
  </code></pre>
  
  <p>});</p>
  
  <p>The store was not able to read the json obtained. Most of the recommendations were to add response headers(Access-Control-Allow-Origin) to the webapp(running at tomcat).
  So I added the response headers like below.</p>
  
  <pre><code>@Path("/query/{qryParam}/json")
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  public static Response jsonResult(@PathParam("qryParam") String qryParam) throws JSONException 
  {
      executeQuery("select {[Measures].members} on columns, {Time.[2010], Time.[2010]} on rows from sales" );
      String json = (new JSONObject(((new ResultSetConvert(result)).toJson()))).toString();
      return Response.ok(json).header("Access-Control-Allow-Origin","*").build();     
  }
  </code></pre>
  
  <p>Even then I get the same error as below</p>
  
  <p><img src="https://i.stack.imgur.com/X2cKd.png" alt="http://i.stack.imgur.com/X2cKd.png"></p>
  
  <p>What am I missing here?</p>
  
  <p>P.S If the url points to a file in the same domain, the store is able to read the json in the file.</p>