0

I have used the following script for accessing my basecamp project details but still it returns the following Error:

XMLHttpRequest cannot load https://********.basecamphq.com/projects.xml. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://******.****.com' is therefore not allowed access. The response had HTTP status code 405.

$.ajax({
    type: 'GET',
    url: 'https://xxxxxxxxx.basecamphq.com/projects.xml',
    dataType: 'json',    
        headers: {
     "Access-Control-Allow-Origin": "*",
     "Authorization":"Basic *********************",
     "Accept":"application/json",
     "Content-Type": "application/json",
     "charset":"=utf-8"
     },
  error: function (request, textStatus, errorThrown) {
         alert('e');

    },

    success: function () {alert('s');}
});

So may i know is it possible to access the basecamp projects using javascript ajax call if so please add some sample code.

Liam
  • 27,717
  • 28
  • 128
  • 190
Sivam G
  • 1
  • 1
  • i think cross-domain problem is there please visit http://stackoverflow.com/questions/6871021/how-to-enable-cross-domain-request-on-the-server – Ankit Kathiriya Dec 09 '15 at 08:36

1 Answers1

1

What you have here is a CORS issue. You are setting the "Access-Control-Allow-Origin": "*" on the ajax request itself, however that header needs to be set on the server side (so on basecamp side). You can't force the server to enable CORS from the client request.

If you don't have access to enable CORS on the basecamp side, then you're going to have to go through a proxy (i.e. set up a proxy which has the same origin as basecamp, enable CORS on it, and then make the ajax request to the proxy directly).

Szilard Muzsi
  • 1,881
  • 2
  • 16
  • 20