-1

I have a problem. Is it possible to make a request to a different domain? For example, I have a website test.com and it has to take some data from http://www.google.lv/search?q=fat+pumpkin. I already have tried jQuery .load method, XMLHttpRequest(), but the result is always the same, I get error: Failed to load https://www.google.lv/search?q=fat+pumpkin&.rtng: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Is there some option to overcome it without PHP or another server language?

Master_A
  • 11
  • 4
  • If the server does not support CORs than you can't do it from the clientside without a proxy. But with google, you should be using their apis for search.... – epascarello Oct 29 '18 at 17:32

1 Answers1

1

The same question as your case : Access-Control-Allow-Origin error sending a jQuery Post to Google API's.

Basically you need to add a crossDomain option for ajax request, example:

$.ajax({
    url: 'https://www.googleapis.com/moderator/v1/series?key='+key,
    data: myData,
    type: 'GET',
    crossDomain: true,
    dataType: 'jsonp',
    success: function() { alert("Success"); },
    error: function() { alert('Failed!'); },
    beforeSend: setHeader
});
Sigit
  • 728
  • 7
  • 12