Elice Ee Elice Ee - 4 months ago 35
jQuery Question

Jquery-No 'Access-Control-Allow-Origin' header is present on the requested resource

I have request json data from other website, but it meets the problem of access control allow origin in header, I have no idea how to set the access control allow origin in header, I'm put my source code in the iis8 to access the json data from another iis8 api source.

type: "GET",
xhrFields: {
withCredentials: false

headers: {
"Access-Control-Allow-Origin: ": "*",
"Access-Control-Allow-Methods: ": "GET",
"Access-Control-Allow-Headers: ": "Authorization",
dataType: "json",
success: function(data) {
error: function() {
alert("An error occurred while processing JSON file.");


These should be in the server, not the client:

"Access-Control-Allow-Origin: ": "*",

To implement that in server, for PHP:

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


Response.AppendHeader("Access-Control-Allow-Origin", "*");

For others, check I want to add CORS support to my server for more information.