L
laredotornado
Hi,
I'm trying to submit a framework-independent post ajax request, but
running into some errors on Google Chrome (Firefox and IE seem to work
fine). Specifically, I receive the error, "Uncaught Error:
INVALID_STATE_ERR: DOM Exception 11" on this line
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
Here is how I'm creating the AJAX request ...
function getXmlHttpRequest() {
var ajaxRequest; // The variable that makes Ajax possible!
try {
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e) {
// Internet Explorer Browsers
try {
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
return ajaxRequest;
}
Any ideas what I'm doing wrong on Chrome? Below is the method the
above line is taken from.
function save() {
var ajaxRequest = getXmlHttpRequest();
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function() {
if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
alert(ajaxRequest.responseText);
}
}
// get the params
var params = serialize(document.getElementById('main'));
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
ajaxRequest.open("POST", "save", true);
ajaxRequest.send(params);
}
I'm on Win XP. Thanks, - Dave
I'm trying to submit a framework-independent post ajax request, but
running into some errors on Google Chrome (Firefox and IE seem to work
fine). Specifically, I receive the error, "Uncaught Error:
INVALID_STATE_ERR: DOM Exception 11" on this line
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
Here is how I'm creating the AJAX request ...
function getXmlHttpRequest() {
var ajaxRequest; // The variable that makes Ajax possible!
try {
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e) {
// Internet Explorer Browsers
try {
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
return ajaxRequest;
}
Any ideas what I'm doing wrong on Chrome? Below is the method the
above line is taken from.
function save() {
var ajaxRequest = getXmlHttpRequest();
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function() {
if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
alert(ajaxRequest.responseText);
}
}
// get the params
var params = serialize(document.getElementById('main'));
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
ajaxRequest.open("POST", "save", true);
ajaxRequest.send(params);
}
I'm on Win XP. Thanks, - Dave