Skip to content

Instantly share code, notes, and snippets.

@jiluhu
Created March 10, 2020 04:09
Show Gist options
  • Save jiluhu/411fbc14a5afc897acb55bf259a2a1c2 to your computer and use it in GitHub Desktop.
Save jiluhu/411fbc14a5afc897acb55bf259a2a1c2 to your computer and use it in GitHub Desktop.
测试跨域
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://localhost:8080/process-api/repository/deployments');
var token= "xxxxx";
xhr.setRequestHeader("x-access-token",token);
xhr.send(null);
xhr.onload = function(e) {
var xhr = e.target;
console.log(xhr.responseText);
}
//header('Access-Control-Allow-Headers:x-requested-with,content-type');
//xhr.setRequestHeader("Access-Control-Allow-Origin","x-requested-with,content-type");
//xhr.setRequestHeader("Content-Type","application/json;charset=UTF-8");
//xhr.setRequestHeader("Access-Control-Allow-Origin","http://localhost:8080");
//Content-Type:multipart/form-data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment