title: getting data from cgi into javascript (ajax)
body: <p>I have made a cgi program in C, which generates HTML, and I would like to replace a part of a HTML page with it.
  So, using jquery I have tried to get the output of my cgi using $.ajax(),$.get() or $.post() but it doesn't work and I found nothing relevant in firefox and chromium's debugger. I run Apache localy, and the logs say it did have a request </p>
  
  <blockquote>
    <p>127.0.0.1 - - [20/May/2013:01:19:32 +0200] "GET /cgi-bin/test_cgi HTTP/1.1" 200 682</p>
  </blockquote>
  
  <p>I have looked for hours, and it seems like people are using the code just like I do but it works for them, not for me, so I'll just paste it and let you take a look to what is wrong</p>
  
  <p>javascript(jquery):</p>
  
  <pre><code>$(document).ready(function() {
      $('#button_ajax').click(function() {
          alert("success1");
          $.get('http://localhost/cgi-bin/test_cgi', function(data) {
                      //$('#ajax').empty().append(data);
              alert("success2");
          });
      });
  });
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>&lt;button id="button_ajax"&gt;Click here!&lt;/button&gt;
  &lt;div id="ajax"&gt;
  &lt;p&gt;Some random test&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>There is a pop-up for "success1", but then nothing for "success2"
  And here is what I get in firefox debugger</p>
  
  <pre><code>&gt; [01:19:32,898] GET http://localhost/cgi-bin/test_cgi [HTTP/1.1 200 OK
  &gt; 2ms]
  </code></pre>
  
  <p>with chromium debugger I get this</p>
  
  <pre><code>XMLHttpRequest cannot load http://localhost/cgi-bin/test_cgi. Origin null is not allowed by Access-Control-Allow-Origin.
  </code></pre>
  
  <p>Anyone up for some recommandations?</p>