title: Ajax long polling with curl command
body: <p>I have my files on my localhost and I am trying to make a HTTP long polling request to my web server which is hosted in localhost:7305. Since the browser makes the call with port 80, I get the error</p>
  
  <pre><code>XMLHttpRequest cannot load. Origin is not allowed by Access-Control-Allow-Origin. No "Access Control Allow Origin" header is present on the request resource.
  </code></pre>
  
  <p>So I designed a php code with curl to make the call:</p>
  
  <pre><code> &lt;?php
   error_reporting(E_ALL);
   ini_set('display_errors', '1');
  
   $ch = curl_init();
  
   curl_setopt($ch, CURLOPT_URL, "http://localhost:7555/test?list=0");
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_PORT, 7555);
  
   curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  
   $out = curl_exec($ch);
  
   curl_close($ch);
  
   echo $out;
  
   ?&gt;
  </code></pre>
  
  <p>And in my JavaScript this is how I make the ajax long polling request:</p>
  
  <pre><code> function longpoll(){
        $.ajax({
          url: "http://localhost/bypass.php",
          type: "GET",
          success: function(m) {
             //update some html element with the response
          },
          error: function(e){
             //Error report
          },
          complete: longpoll
          });
   }
  </code></pre>
  
  <p>Its supposed to return a list of strings, but I am getting the error</p>
  
  <pre><code> GET http://localhost/bypass.php 500 (Internal Server Error)
   f.support.ajax.f.ajaxTransport.send
   f.extend.ajax
   longpoll
  </code></pre>
  
  <p>I am not sure whats causing this? could it be since ajax is making async call? The web server is in spring and returns a DeferredResult object. Any help is appreciated</p>