jQuery 経由でチケットを作成しようとしていますが、次のエラーが発生しました。
エラー: http://itsmapdv.bmc.com:8008/jwt/loginの XMLHttpRequest にはCross Origin Resource Sharing (CORS) が必要です。
コード:
function getAuthorisationCode(pstrUsername, pstrPassword) {
//Get the auhorisation code from the server. We accept the user name and the password, and return the code.
console.log("Starting GetAuthorization");
var xmlhttp;
xmlhttp = new XMLHttpRequest();
//Define a POST request. Notice I set the last parameter to false, which means it goes out synchronously. I need this as I need
//to wait until I get the code before moving on.
xmlhttp.open("POST", "http://itsmapdv.bmc.com:8008/jwt/login", false);
//Add a HTTP header to request to specify the content-type.
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//Send the request. The POST body is included here.
xmlhttp.send("username=" + pstrUsername + "&password=" + pstrPassword); //Failing here
console.log(xmlhttp.responseText);
//If we get HTTP200 back we're done and we can return the code.
if (xmlhttp.status == 200) {
return "AR-JWT " + xmlhttp.responseText;
}
}
ここでこの CORS 呼び出しを行うにはどうすればよいでしょうか?