Jump to content

[SOLVED] Works with Firefox but fails with IE


stockton

Recommended Posts

Can someone please explain to me why the following code works perfectly in Firefox but fails in Internet Explorer?

function getXMLHttpRequest () {
    try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {};
    try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {};
    try { return new XMLHttpRequest(); } catch(e) {};
    return null;
    }

// Make the XMLHttpRequest object
var http = getXMLHttpRequest();

function sendRequest(Mode, Event, CardNumber)
        {
// Call PHP script for requests
/*  For debug purposes */
document.getElementById("loadingNode").value = "Calling TI3SGM-3.php";
         http.open('get', 'TI3SGM-3.php?EventID='+Event+'&MemberNum='+CardNumber);
         http.onreadystatechange = handleClientDataResponse;
         }

function handleClientDataResponse()
    {
//	document.getElementById("loadingNode").value = "Ons wag vir 'n wenner";

    if(http.readyState == 4 && http.status == 200)
        {
        // Text returned from the PHP script
        var response = http.responseText;
        if(response)
            {
            // UPDATE ajaxResponse content
            var parts = response.split("|");
            var MemberName = document.getElementById("MemberName");
            if (!MemberName)
                {
                alert("We have a problem!");
                }
//            alert(response);
            document.getElementById("CNumber").innerHTML = parts[0];
            document.getElementById("MemberName").innerHTML = parts[1];
            var SlotsValue=parseInt(parts[2],10);
            if (isNaN(SlotsValue)) SlotsValue=0;
            document.getElementById("SlotsValue").innerHTML = SlotsValue;
            var SlotsTurnover=parseInt(parts[3],10);
            if (isNaN(SlotsTurnover)) SlotsTurnover = 0;
            document.getElementById("SlotsTurnover").innerHTML = SlotsTurnover;
            var SlotsIssued=parseInt(parts[4],10);
            if (isNaN(SlotsIssued)) SlotsIssued = 0;
            document.getElementById("SlotsIssued").innerHTML = SlotsIssued;

            var TablesValue=parseInt(parts[5],10);
            if (isNaN(TablesValue)) TablesValue = 0;
            document.getElementById("TablesValue").innerHTML = TablesValue;
            var TablesTurnover=parseInt(parts[6],10);
            if (isNaN(TablesTurnover)) TablesTurnover = 0;
            document.getElementById("TablesTurnover").innerHTML = TablesTurnover;
            var TablesIssued=parseInt(parts[7],10);
            if (isNaN(TablesIssued)) TablesIssued = 0;
            document.getElementById("TablesIssued").innerHTML = TablesIssued;

            document.getElementById("Earned").innerHTML = SlotsValue+TablesValue;

            var BonusValue=parseInt(parts[8],10);
            if (isNaN(BonusValue)) BonusValue = 0;
            document.getElementById("BonusValue").innerHTML = BonusValue;
            var BonusIssued=parseInt(parts[9],10);
            if (isNaN(BonusIssued)) BonusIssued = 0;
            document.getElementById("BonusIssued").innerHTML = BonusIssued;

            document.getElementById("Total").innerHTML=SlotsValue+TablesValue+BonusValue;
            var IssuedValue=parseInt(parts[10],10);
            if (isNaN(IssuedValue)) IssuedValue = 0;
            IssuedValue = SlotsIssued+TablesIssued+BonusIssued;
            document.getElementById("IssuedValue").innerHTML = IssuedValue;
            var TotalValue=SlotsValue+TablesValue+BonusValue;
            var OutstandingValue=TotalValue-IssuedValue;
            document.getElementById("OutstandingValue").innerHTML = OutstandingValue;
		var MayIssue=parseInt(parts[11],10);
            if ((OutstandingValue > 0) && (MayIssue == 1))
                {
                document.getElementById("Issue").disabled=false;
                document.getElementById("Issue").src = 'images/issue.png';
                }
            document.getElementById("loadingNode").value = "";
//            document.getElementById("ajaxResponse").value = response;
//            confirm(parts[0]);
            }
        }
        else if (http.readyState < 4)
            {
//            document.getElementById("loadingNode").value = "Loading........";
		ShowAjaxStatus(http.readyState);
}
function ShowAjaxStatus(What)
{
document.getElementById("loadingNode").value = "Ons wag";
if(What == 0)
	{
	document.getElementById("loadingNode").value = "Uninitialized........";
	}
else
if(What == 1)
	{
	document.getElementById("loadingNode").value = "Loading........";
	}
else
if(What == 2)
	{
	document.getElementById("loadingNode").value = "Loaded........";
	}
else
if(What == 3)
	{
	document.getElementById("loadingNode").value = "Interactive........";
	}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.