title: AJAX post request gives Origin null is not allowed by Access-Control-Allow-Origin
body: <p>I've got a simple HTML test file, to a server to receive a JSON object from java script, that has a  in it that creates a JSON file and then tries to send this JSON to a localhost server like this.</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;
  &lt;body&gt;
    &lt;button type="button" onclick="doPost()"&gt;
      POST
    &lt;/button&gt;
    &lt;script src="/home/tcremers/projects/utopiaPlugins/src/3dmUtopia/js/libs/jquery.js"&gt;&lt;/script&gt;
    &lt;script&gt;
    function doPost() {
      var JSONdata = {jsonobject}
  
      try{
      $.ajax({
          type: 'POST',
          url: "http://localhost:8080/validation-web/annotation/persist",
          contentType:'application/json',
          data: JSON.stringify(JSONdata),
          dataType:'json'
      });
      console.log("do you even output")
      }
      catch(e) {
          console.log("errrrorrrrr")
          conlole.log(e)
      }
  }
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The server is has some JAVA code that sets it to just return the json object in the command terminal where you first started the server.
  But before it even reaches the server i chromium gives "Origin null is not allowed by Access-Control-Allow-Origin".</p>
  
  <p>Now i know that cross domain AJAX is initially not allowed because of security issues and I've also read that you can disable this. I only haven't seen any post with a clear answer on how to disable this security feature.
  For example I've tried to run chromium with all security disabled from the command line and that didn't do it. I also read a lot about that i have to set the Access-Control-Allow-Origin to " * ", or to the directory path of where you run your java script from, so cross domain AJAX would be enabled. Maybe it's me, but i haven't seen any clear explanation of where to actually change or insert this command.
  I've also already tried to use jsonp with a 'GET' request but that doesnt work either.</p>
  
  <p>The actual server i know works, since I've tested it with a curl command.</p>
  
  <pre><code> curl -X POST -H "Content-Type: application/json" -d '{the JSON object}' http://localhost:8080/validation-web/annotation/persist
  </code></pre>
  
  <p>Now the actual weird thing to me is this.
  The main java script code where i want to use this AJAX request is not running in a web browser at all (and should in my opinion not have any problems with the cross domain restrictions) and already contains a lot of other server requests too. Still this script gives a similar error on this particular AJAX request too.
  This is the error message: <code>"XMLHttpRequest cannot load, http://localhost:8080 etc..., Cannot make any requests from null</code>.</p>
  
  <p>Does anybody know what my problem is here or could point me in the right direction of solving this error? It would be greatly appreciated.</p>