2

I'm trying to mimic this curl command to an ajax call.

curl -H 'X-Auth-Id' 'someid' http://someurl.com/api/posts

I've tried using

$.ajax({
    url: 'http://someurl.com/api/posts',
    type: 'get',
    headers: {
        'X-User-Id': userId
    },
    success: function(data) {
        console.log(data);
    }
});

But I seem to be getting an Invalid status code error, which I do not get when using curl from bash.

worldofjr
  • 3,868
  • 8
  • 37
  • 49
justindra
  • 166
  • 1
  • 9
  • 1
    See [Loading cross domain html page with jQuery AJAX -- jQuery Ajax Notes](http://stackoverflow.com/questions/15005500/loading-cross-domain-html-page-with-jquery-ajax/17299796#17299796). **cURL** is a command line tool for getting or sending files using URL syntax and it is not affected by the **same origin policy**, by the other hand, due to browser security restrictions, most Ajax requests are subject to the same origin policy; – jherax Mar 11 '15 at 19:04

0 Answers0