title: Using ajax to make a curl request
body: <p>This <a href="https://stackoverflow.com/a/6230300/67258">answer</a> has helped me largely but hasn't fully resolved my issues. I'm using code similar to that, which is:</p>
  
  <pre><code>function getResponse() {
  
      var the_url = "http://www.myurl.com/api/get";
  
      $.ajax({
        url: the_url,
        dataType: 'jsonp',
        type: 'get',
        success: function(data) {
          var json_response = data;
          alert(data);
        }
      });
  }
  </code></pre>
  
  <p>Basically, instead of just posting a url I need to post a curl because of authentication.</p>
  
  <p>The example works fine with the simple url, but what I am wanting to use for 'the_url' is this:</p>
  
  <pre><code>var the_url = 'curl -u username:password "http://www.myurl.com/api/get"';
  </code></pre>
  
  <p>This is where I am having issues which means the success statement is never reached.</p>
  
  <p>What is the best way to resolve this, and if it's not achievable could someone recommend the best workaround?</p>
  
  <p>Thanks in advance.</p>