-1

ERROR IN AJAX REQUEST

http://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

MY CODE

var srv_url = 'https://api-domain.com/api/index.php?type=join&meetingID=test01&moderatorPW=mp&fullName=John';
    var auth_token = 'e6a83f2844c9cdd4729b69dc851f96c1c073a23b4f37eb7cdec83bf8c9c7a06d'

    $.ajax({
      url: srv_url,
      type: 'get',
      beforeSend: function(xhr){
        xhr.setRequestHeader("Authorization", auth_token);
      },
      success: function(res){
        console.log(res)
      },
      error: function(e){
        console.log(e)
      }
    })

BUT WORKING IN POSTMAN

enter image description here

If there are CORS related problems, why this request working in postman in the same machine. Please help me, am I doing something wrong in my ajax code.

Suman Biswas
  • 93
  • 1
  • 11

1 Answers1

0

You need to allow cross origin access at server side using :

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

You will find more details here

Paritosh Mahale
  • 1,238
  • 2
  • 14
  • 42