the script below works when I run it through IE, but not when I run it through Chrome or Firefox. I get "Invocation errors occurred". Does anyone know why this is happening and what I need to do to fix it?
var isIE8 = window.XDomainRequest ? true : false;
var dictionary = createCrossDomainRequest();
var url = 'http://www.math.sjsu.edu/~foster/dictionary.txt';
makeRequest();
function createCrossDomainRequest() {
var request;
if (isIE8) {
request = new window.XDomainRequest();
}
else {
request = new XMLHttpRequest();
}
return request;
}
function makeRequest() {
if (dictionary) {
if(isIE8) {
dictionary.onload = requestSucceeded;
dictionary.open("GET", 'http://www.math.sjsu.edu/~foster/dictionary.txt', true);
dictionary.send();
}
else {
dictionary.open("GET", 'http://www.math.sjsu.edu/~foster/dictionary.txt', true);
dictionary.withCredentials = true;
dictionary.onreadystatechange = handler;
dictionary.send();
}
}
else {
alert("No Invocation Took Place");
}
}
function handler() {
if (dictionary.readyState === 4){
if (dictionary.status == 200){
requestSucceeded();
}
else {
alert("Invocation Errors Occurred");
}
}
}
function requestSucceeded() {
resultText = dictionary.responseText;
document.getElementById( 'demo' ).innerHTML += resultText;
}
dictionary.withCredentials = true;does it make any difference?