我正在尝试构建一个休息客户端来将数据发布到 Redmine API。我认为我无法更改 Redmine(服务器端)API 上的任何内容。给予访问权。我已经在本地安装了 Redmine bitnami 堆栈(Redmine -> localhost/redmine)。客户端文件位于 localhost:8080
$(document).ready(function(){
$("#submit").on('click', function(){
// send ajax
$.ajax({
url: 'http://localhost/redmine/projects.json',
type : "post",
crossDomain: true,
dataType : 'json',
headers: { 'X-Redmine-API-Key': 'admin' },
data : JSON.stringify({
"project": {
"name": "MANOJ",
"identifier": "MANOJ-perera",
"description": "This is a des"
}
}),
success : function(result) {
alert("Sucess");
console.log(result);
},
error: function(xhr, resp, text) {
console.log(xhr, resp, text);
}
})
});
});
我收到以下错误。
XMLHttpRequest cannot load http://localhost/redmine/projects/11n. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 404.
我该如何解决这个问题。请帮忙。