Retrieving data with cross-domain requests

Hey guys,

I’m having trouble trying to make a script that gets the source code of a website in a different domain. I tried two requests, one with ajax and one with CORS, both found online with a little search. But none of them are working because the server I’m trying to access doesn’t allow it. It also doesn’t have an API :confused:


url: '',
     success: function(data) { 

I get the following error:

XMLHttpRequest cannot load No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ is therefore not allowed access.

So, since I have no way of putting that header on the resource server, I can’t get any data by this method?
Is there a different way of doing this?

p.s: There is an API about solar radiation, but they only have data for the US, and all the coordinates I need to consult are in south america. . If anyone knows a good and free one that also has info for different countries it would be great!

You can use or JSONP usually to treat these sort of things, but I do not understand what you are trying to do. The link you posted is not sending you any json data, it is sending you html, how do you expect to get anything in an ajax request?

1 Like