0

Access to XMLHttpRequest at 'https://happydesertsafari.com/happy-new/getLocations.php?getAll=true&_=1578818763165' from origin 'https://www.happydesertsafari.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

var dropdownData = [];
   $.ajax({
     url: 'getLocations.php',
     dataType: "json",
     data: 'getAll=true',
     cache: false,
     success: function(employeeData) {
     dropdownData = employeeData
        }
    });
  • Does this answer your question? [Why does my JavaScript code get a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error when Postman does not?](https://stackoverflow.com/questions/20035101/why-does-my-javascript-code-get-a-no-access-control-allow-origin-header-is-pr) – Basil Jan 12 '20 at 09:37
  • quick quiz: does `www.a.b` equal `a.b` ... therefore it's **NOT** same domain – Jaromanda X Jan 12 '20 at 09:37
  • @Basil - answer the quick quiz too :p – Jaromanda X Jan 12 '20 at 09:37

1 Answers1

0

by trying this your issue will get fixed

If you are using Php then Put this on top of your php page:

header('Access-Control-Allow-Origin: *');

and if you are using js use like this

jQuery.support.cors = true;
$.ajax({
 url: "getLocations.php",
 dataType: "json",
 data: 'getAll=true',
 cache: false,
 success: function(employeeData) {
 dropdownData = employeeData
    },
error: function(jqXHR, textStatus, ex) {
    alert(textStatus + "," + ex + "," + jqXHR.responseText);
  }
});
Ishwar Gagare
  • 723
  • 3
  • 9