P
pbd22
Hi.
I am having a problem with an XMLHTTP request. The request itself
works just fine. But, if it evaluates to false I need to return the
error by adding to the errMsg txt as such:
errMsg += "<li>The code you entered was wrong.</li>";
This happens inside the http_request.onreadystatechange function.
The problem is, even when the request evaluates to false and the error
is added to the errMsg string, the message never actually appears in
the results. Every other error message does, just not the one
generated by the XMLHTTP request.
Any idea why this is happening?
Thanks.
if (strng15 == "") {
errMsg += "<li>You need to enter a code.</
li>";
} else {
try {
var http_request = false;
url = "data_code.aspx?code=" +
strng14;
if (window.XMLHttpRequest) { //
Mozilla, Safari, ...
http_request = new
XMLHttpRequest();
if
(http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) { //
IE
try {
http_request = new
ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new
ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up Cannot
create an XMLHTTP instance');
//return BOOL_RETURN_STATUS;
}
http_request.onreadystatechange =
function() {
alert(http_request.responseText);
var jsonObj =
http_request.responseText.parseJSON();
alert(jsonObj);
if (http_request.readyState == 4)
{
document.getElementById("loading").style.visibility = "hidden";
if (http_request.status ==
200)
{
var result =
jsonObj.match.result;
alert(result);
if (result === false) {
errMsg += "<li>The code
you entered was wrong.</li>";
}
}
}
};
http_request.open('POST', url, true);
http_request.setRequestHeader('Content-
Type', 'application/x-www-form-urlencoded; charset=UTF-8');
http_request.send(null);
with
(document.getElementById("loading")) {
style.visibility = "visible";
}
} catch(e){
[SNIP... ]
I am having a problem with an XMLHTTP request. The request itself
works just fine. But, if it evaluates to false I need to return the
error by adding to the errMsg txt as such:
errMsg += "<li>The code you entered was wrong.</li>";
This happens inside the http_request.onreadystatechange function.
The problem is, even when the request evaluates to false and the error
is added to the errMsg string, the message never actually appears in
the results. Every other error message does, just not the one
generated by the XMLHTTP request.
Any idea why this is happening?
Thanks.
if (strng15 == "") {
errMsg += "<li>You need to enter a code.</
li>";
} else {
try {
var http_request = false;
url = "data_code.aspx?code=" +
strng14;
if (window.XMLHttpRequest) { //
Mozilla, Safari, ...
http_request = new
XMLHttpRequest();
if
(http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) { //
IE
try {
http_request = new
ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new
ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up Cannot
create an XMLHTTP instance');
//return BOOL_RETURN_STATUS;
}
http_request.onreadystatechange =
function() {
alert(http_request.responseText);
var jsonObj =
http_request.responseText.parseJSON();
alert(jsonObj);
if (http_request.readyState == 4)
{
document.getElementById("loading").style.visibility = "hidden";
if (http_request.status ==
200)
{
var result =
jsonObj.match.result;
alert(result);
if (result === false) {
errMsg += "<li>The code
you entered was wrong.</li>";
}
}
}
};
http_request.open('POST', url, true);
http_request.setRequestHeader('Content-
Type', 'application/x-www-form-urlencoded; charset=UTF-8');
http_request.send(null);
with
(document.getElementById("loading")) {
style.visibility = "visible";
}
} catch(e){
[SNIP... ]