问题描述: - 我试图调用不同域的Web服务(即系统之间没有本地连接),所以我收到错误: - "无法加载https://sap.atlassian.net/:响应预检无效(重定向)"
var username = "pra@sap.com";
var password = "Sa8";
$.ajax({
type: 'POST',
data: data1,
url: 'https://sap.atlassian.net',
dataType: 'json',
contentType: "application/json",
crossDomain: true,
ProcessData: true,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Methods": "POST, GET, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "accept, X-Custom-Header, x-requested-with, X-Auth-Token, Content-Type"
},
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Atlassian-Token", "no-check");
xhr.setRequestHeader('Authorization', "Basic" + btoa(username + ":" + password));
},
success: function(data) {
console.log("success");
},
error: function(e) {
console.log(e);
}
});
答案 0 :(得分:0)
首先,您可能需要仔细检查网址。必须有一些相对的URL。
你能发布详细的堆栈跟踪吗?
PS:公开使用您的用户名/密码总是不好的做法。你应该立即更改你的密码!