new XMLHttpRequest cannot run on Firefox

The script below work perfectly in IE for the XML respond. But seems i cant figured out how to run on Firefox or Chorme. Try few modification but still not able to run it. Kindly need assistant.

<script type="text/javascript" language="javascript"> 
var xmlhttp;
var timeStamp;

var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate() //remove the + 1  afterwards
var year = currentTime.getFullYear()
var hour = currentTime.getHours()
var minutes = currentTime.getMinutes()
var second = currentTime.getSeconds() + 1


timeStamp = day + "/" + month + "/" + year + " " + hour + ":" + minutes + ":" + second;



function on_click()

{



    var xmlToSend = "<?xml version='1.0' encoding='utf-8'?>";
    xmlToSend += "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' ";
    xmlToSend += "xmlns:xsd='http://www.w3.org/2001/XMLSchema' ";
    xmlToSend += "xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>";
    xmlToSend += "<soap:Body><Welcomescreen Sender='SENDERDDRESS' TimeStamp='28/10/2009 16:49:31' Type='1' Workshop='SG' RequireAppointmentDate='2010/01/04' xmlns='http://www.SENDERDDRESS.com/integration'/>";
    xmlToSend += "</soap:Body></soap:Envelope>";

    /


    var xmldoc = new ActiveXObject("Microsoft.XMLDOM"); 
    xmldoc.loadXML(xmlToSend); 


    if (window.XMLHttpRequest)
      {/ / code
    for IE7 + , Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}


xmlhttp.onreadystatechange = state_Change;

xmlhttp.open("POST", "http://SENDERDDRESS:4509/resd", false);
xmlhttp.setRequestHeader("SOAPAction", "http://www.mhe.com/SRP/requestVinRequest");
xmlhttp.setRequestHeader("Content-Type", "text/xml");
xmlhttp.setRequestHeader("User-Agent", "Jakarta Commons-HttpClient/3.0.1");
xmlhttp.setRequestHeader("Host", "SENDERDDRESS:4509");
xmlhttp.setRequestHeader("Content-Length", "391");
xmlhttp.send(xmldoc);



var objResponse = document.getElementsByTagName("Appointment");

objResponse.innerText = xmlhttp.responseXML.xml;

}

function state_Change()

{
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            txt = "<table align='right' border='1' width='400'><tr><th><font color='#d9d7d7' size='4' face='verdana'>Time</font></th><th><font color='#d9d7d7' size='4' face='verdana'>Plate No.</font></th><th><font color='#d9d7d7' size='4' face='verdana'>Status</font></th></tr>";
            x = xmlhttp.responseXML.documentElement.getElementsByTagName("Appointment");
            for (i = 0; i < x.length; i++) {

                xx = x[i].getElementsByTagName("AppointmentTime"); {
                    try {
                        txt = txt + "<td><font size = 5>" + xx[0].firstChild.nodeValue + "</font></td>";
                    } catch (er) {
                        txt = txt + "<td> </td>";
                    }
                }

                xx = x[i].getElementsByTagName("NumberPlate"); {
                    try {
                        txt = txt + "<td><font size = 5>" + xx[0].firstChild.nodeValue + "</font></td>";
                    } catch (er) {
                        txt = txt + "<td> </td>";
                    }
                }

                xx = x[i].getElementsByTagName("statusCode"); {
                    try {
                        txt = txt + "<td><font size = 5>" + xx[0].firstChild.nodeValue + "</font></td>";
                    } catch (er) {
                        txt = txt + "<td> </td>";
                    }
                }
                txt = txt + "</tr>";
            }
            txt = txt + "</table>";
            document.getElementById('txtCDInfo').innerHTML = txt;
        } else

        {


        }

    }

}
</script> 
1
задан Greg 9 April 2014 в 19:08
поделиться