I have this get request to a server. This site is hosted on a dev server, but I want to point this get request to a production server.
var requestList = new XMLHttpRequest();
requestList.onreadystatechange = function() {
if (requestList.readyState==4&&requestList.status==200) {
display(JSON.parse(requestList.responseText));
}
};
requestList.open('GET','<link/to/php/server>',true);
requestList.withCredentials = true;
I'm getting a cors error. But, I can run this request from something like PowerShell and it works with the following code:
$url = "<link/to/php/server>"
$wc = New-Object System.Net.WebClient
$wc.UseDefaultCredentials = $true
$response = $wc.DownloadString($url)
$df = ConvertFrom-Json $([String]::new($response))
The PowerShell code just uses windows credentials. Since the PowerShell code works, I know I should be able to query the production server. But how to do it with JavaScript XMLHttpRequest?