0

In the code, I'm trying to use another websites login check mechanism to my website. through the below code I'm getting the correct reponse ID as well but login can't be completed because of the CORS error. Now when I enabled CORS enabler extension in my browser it worked perfectly but when that is disabled CORS error is generated.

p.s I know what CORS is and it's obvious to generate the error but how do I pass that error by adding headers?

$.ajax({
        type: 'POST',
        data: data,
        url: 'http://xyz.in/xyz/login_check.php',
        beforeSend: function(xhr) {
            document.getElementById("error").innerHTML = "Checking data... ";
        },
        success: function(responseID) {
                console.log(responseID);
            if(responseID === 'S') {
                window.location = 'main.php';
            }
        }
    });
});
Sayak Sen
  • 11
  • 1
  • 4

1 Answers1

0

You'll need to make a server-side change to send the correct headers. See Access-Control-Allow-Origin in the MDN docs.

John Ellmore
  • 2,209
  • 1
  • 10
  • 22