Hi,
I am trying to redirect and open a site using XMLHttpRequest from a ColdFusion page
Here is my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Pass Login</title>
<cfoutput>
<script type="text/javascript">
var url = 'https://bi.mySite.com/cf/';
var xhr = createCORSRequest('GET', url);
xhr.setRequestHeader('X-User-Header', '#userId#');
if (xhr){
xhr.onload = function(){
//do something with request.responseText
if(xhr.status === 200){
console.log('2')
}
};
xhr.send();
}
function createCORSRequest(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
// XHR for Chrome/Firefox/Opera/Safari.
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
// XDomainRequest for IE.
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
// CORS not supported.
xhr = null;
}
return xhr;
}
</script>
</cfoutput>
</head>
</html>
I am getting 200 code in chrome but it is not opening the site.
Am I missing something?
Thanks!