This is pretty much a known standard error but unable to fix the same using existing Stackoverflow posts.
XMLHttpRequest cannot load https://myserver.com/context/
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'https://www.otherwebsite.com' is therefore not allowed access.
The response had HTTP status code 405.
Following is the code I have -
function setHeader(xhr) { xhr.setRequestHeader("Access-Control-Allow-Origin", "*"); } var url = "https://myserver.com/context/"; $.ajax({ url: url, type: 'GET', dataType:'json', success: function(data) { _this.question(data.question); _this.questionId(data.questionId); _this.choices(data.choices); }, error: function() { console.log("ERROR in getting microquestion"); }, beforeSend: setHeader });