Arya Arya - 1 year ago 122
PHP Question

CORS header 'Access-Control-Allow-Origin' missing in php

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 (Reason: CORS header 'Access-Control-Allow-Origin' missing).

My ajax code is,

type: "POST",
url: "",
data: {username: "abcd",password:"abcd"},
dataType: "html",
success: function (data) {

Answer Source

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

<?php header('Access-Control-Allow-Origin: *'); ?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download