2

In my web application, try to pass data to another domain with ajax call. But it shows error like Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://example.com/auth/webschool/test.php. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

My ajax code is,

 $.ajax({
                type: "POST",
                url: "http://example.com/auth/webschool/test.php",
                data: {username: "abcd",password:"abcd"},
                 dataType: "html",
                success: function (data) {
                 alert(data);
                }
            });
Arya
  • 504
  • 2
  • 8
  • 31

1 Answers1

6

Just put this line on test.php, hope it will work

<?php header('Access-Control-Allow-Origin: *'); ?>
Waleed Ahmed Haris
  • 1,229
  • 11
  • 17