Hej igen
Beklager forsinkelsen.
I GetXmlHttpObject() kan ses alle de forsøg jeg har prøvet.
Jeg er blevet lidt usikker på om det kan være denne der fejler i stedet.
function GetXmlDoc(inputXml) {
if (window.DOMParser) {
parser = new DOMParser();
xmlDoc = parser.parseFromString(inputXml, "text/xml");
}
else // Internet Explorer
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(inputXml);
}
return xmlDoc;
}
Min xmlhttp kode ser sådan ud pt.
var xmlhttp;
function loadData() {
document.getElementById("txtStatus").innerHTML = 'Loading data...';
document.getElementById("txtDebug").innerHTML = "1";
nowDateTime = new Date();
if (lastRequest == "") {
nowDateTime.setDate(nowDateTime.getDate() - 7);
lastRequest = "/" + nowDateTime.getFullYear() + "/" + (parseInt(nowDateTime.getMonth()) + 1) + "/" + nowDateTime.getDate() + "/" + nowDateTime.getHours() + "/" + nowDateTime.getMinutes() + "/" + nowDateTime.getSeconds();
nowDateTime = new Date();
}
currentRequest = "/" + nowDateTime.getFullYear() + "/" + (parseInt(nowDateTime.getMonth()) + 1) + "/" + nowDateTime.getDate() + "/" + nowDateTime.getHours() + "/" + nowDateTime.getMinutes() + "/" + nowDateTime.getSeconds();
var url = "
http://pit-fleet-view/vehicleinformationservice/Service.svc/vis/vehicles/coordinates" + lastRequest;
lastRequest = currentRequest;
xmlhttp = GetXmlHttpObject();
//xmlhttp = createXMLHttpRequest();
if (xmlhttp == null) {
alert("Your browser does not support AJAX!");
return;
}
xmlhttp.onreadystatechange = loadDataDone;
xmlhttp.open("GET", url, true);
xmlhttp.send(null);
}
function loadDataDone() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200 || xmlhttp.status == 304) {
document.getElementById("txtStatus").innerHTML = '';
DrawRoutes(xmlhttp.responseText);
document.getElementById("txtDebug").innerHTML = 'OK: ' + " " + xmlhttp.status + " " + xmlhttp.statusText;
}
else {
document.getElementById("txtStatus").innerHTML = 'Error: ' + " " + xmlhttp.status + " " + xmlhttp.statusText;
}
}
}
function GetXmlHttpObject() {
/*if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
alert("Your browser does not support XMLHTTP!");
}*/
/*try { return new XMLHttpRequest(); } catch (e) { }
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { }
alert("XMLHttpRequest not supported");
return null;*/
/*if (window.XMLHttpRequest) {
// chrome, Firefox, IE7+, Opera, Safari
return new XMLHttpRequest();
}
// IE6
try {
// The latest stable version. It has the best security, performance,
// reliability, and W3C conformance. Ships with Vista, and available
// with other OS's via downloads and updates.
return new ActiveXObject('MSXML2.XMLHTTP.6.0');
} catch (e) {
try {
// The fallback.
return new ActiveXObject('MSXML2.XMLHTTP.3.0');
} catch (e) {
alert('This browser is not AJAX enabled.');
return null;
}
} */
/*if (!window.XMLHttpRequest) {
window.XMLHttpRequest = function() {
var a = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
var o = null;
for (var i = 0, j = a.length; i < j; i++) {
try {
if (o = new ActiveXObject(a[i])) return o;
}
catch (e) { };
}
return a = o = null;
}
}*/
/*
// Hvis XMLHttpRequest understøttes, så returner en ny instans
if (window.XMLHttpRequest) return new XMLHttpRequest();
// Ellers - hvis ActiveX heller ikke understøttes, så returner null
if (!window.ActiveXObject) return null;
// Ellers oprettes et array med de forskellige objekt versioner - nyeste først
var a = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
var o = null;
// For hver version ...
for (var i = 0, j = a.length; i < j; i++) {
// Undgå at generere fejl, hvis versionen ikke genkendes
try {
// Hvis objektet kan oprettes, så returner det
if (o = new ActiveXObject(a[i])) return o;
}
catch (e) { };
}
// Hvis intet lykkedes, ryddes op og der returneres null
return a = o = null;
*/
if (window.ActiveXObject) {
// try XMLHTTP ActiveX (Internet Explorer) version
return new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
// browser has native support for XMLHttpRequest object
return new XMLHttpRequest();
//return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
(function() {
if (window.XMLHttpRequest) return;
var o = null, s,
a = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
for (var i = 0, j = a.length; i < j; i++) {
s = a[i];
try {
if (o = new ActiveXObject(s)) break;
}
catch (e) { };
}
window.XMLHttpRequest = o ? function() { return new ActiveXObject(s) } : null;
o = null;
})();
function createXMLHttpRequest() {
try { return new XMLHttpRequest(); } catch (e) { }
try { return new ActiveXObject("Microsoft.XMLDOM"); } catch (e) { }
alert("XMLHttpRequest not supported");
return null;
}