My code is relatively simple. I have a URL, which is defined before the request is sent, I then have a $.get()
request, which I expect to return back a JSON object. The code is below.
var url = "url"; //Removed for clarity
$.get(url, function (data) {
alert("hi");
});
The url being used within the request is correct. I have copied and pasted the code into my browser and I receive the response that I expect from the endpoint.
However when this JQuery code is executed, the callback function is not called and the alert is not fired. Why is this happening?
Edit: Forgot to post the error message I found in the console.
I'm receiving this:
2Initial%20Loan#:1 Access to XMLHttpRequest at
'-snip url-' from
origin 'https://localhost:44358' has been blocked by CORS policy: No
'Access-Control-Allow-Origin' header is present on the requested resource.
Will it have anything to do with the GET request not working?