Error when using AJAX Call

I am using an Ajax call to view a page within a page. I get an error when I try to open it. This works in IE 11 and below, Firefox, and Legacy Edge.


function myAjaxCall(id, url){

var req = false;

try{

req = new ActiveXObject("Msxml2.XMLHTTP");

}catch (e){

try{

req = new XMLHttpRequest();

} catch (e){

req = false;

}

}

var element = document.getElementById(id);

if(!element){

alert("Bad ID" + id +"passed.");

return;

}

if (req){

req.open("GET", url, true);

req.send();

element.innerHTML = req.responseText;

}else{

element.innerHTML = "Sorry, your browser does not support this.";

}

}


I get this error when trying to open it:

Access to XMLHttpRequest at 'file:///C:/Users/(..link to page its opening).html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, edge, https, chrome-untrusted.

What settings do I need to enable/disable to allow this to work like it did before the Edge Chromium Update? Or is there a way to do this with JavaScript?

Are you using the latest version of the Microsoft Edge?

Try report this issue using the feedback option, take a look at How to Report a Feedback/Bug to Microsoft Edge’s Team? - Microsoft Community

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Yes I am using the most recent version.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

In this case, report this issue using the feedback option as I mentioned earlier.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated March 13, 2022 Views 714 Applies to: