0

i am trying to send an HTTP request to specific website and i am facing error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.google.com/. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

say for instance that i want to send request to Google.com and receive the HTML response. my code was written using JQUERY AJAX:

function sendRequest(URL) {
          $.ajax({
            type:'GET',
            url:URL,
            success:function(result){console.log(result);}
          });
        }
  • 4
    Short answer is you cannot unless the target site has explicitly allowed it via CORS or some other explicit method of allowing it. This is a foundational security measure and cannot be bypassed. – Dark Falcon Sep 13 '16 at 15:31
  • 1
    Possible duplicate of [Ajax Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource](http://stackoverflow.com/questions/23959912/ajax-cross-origin-request-blocked-the-same-origin-policy-disallows-reading-the) – VLAZ Sep 13 '16 at 15:31
  • Think the message says it all "disallows reading the remote resource at https://www.google.com/. (Reason: **CORS header 'Access-Control-Allow-Origin' missing**)." – Endless Sep 13 '16 at 15:33
  • do you need a response? if not, use a form, img, or beacon. – dandavis Sep 13 '16 at 16:08

1 Answers1

0

Maybe it can help you : https://cloud.google.com/storage/docs/cross-origin#Troubleshooting%20CORS-Related-Problems

Look this one also : Access-Control-Allow-Origin error sending a jQuery Post to Google API's

Community
  • 1
  • 1
jean-max
  • 1,640
  • 1
  • 18
  • 33