Hallo zusammen,
ich habe ein Problem. Ich habe ein Offline-Javascript-Projekt. Klingt doof, ist aber so. Dabei möchte ich gerne offline eine XML-Datei per Javascript einlesen und dann dort weiterverarbeiten. Das habe ich mit Ajax probiert. Firefox macht alles ohne Probleme. Der Internet Explorer meldet bei meiner xmlrequest . open - Funktion ein "Access denied".
Gibt es irgendwie eine Möglichkeit, dies zu umgehen?
Ich benutze folgenden Javascript
function ajaxRequest(url, method, handle, data)
{
this.req = null;
this.url = url;
this.method = method;
this.handle = handle;
this.data = data;
this.sendRequest = function()
{
var self = this;
try {
this.req = new XMLHttpRequest();
}
catch (e) {
try {
this.req = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
this.req = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed) {
this.req = null;
}
}
}
if (this.req == null) {
alert("Error creating request object!");
}
this.req.open(this.method, this.url, true);
this.req.onreadystatechange = function()
{
switch(self.req.readyState) {
case 4:
self.handle(self.req);
break;
default:
return false;
break;
}
}
this.req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
this.req.send(this.data);
}
}
und rufe die Funktion dann später so auf:
function startUp(req)
{
xmlDoc = req.responseXML;
// Mache irgendwas lustiges mit dem erhaltenen XML ...
}
window.onload = function() {
var ajaxReq = new ajaxRequest("xml/inkconsumption.xml","GET",startUp,null);
ajaxReq.sendRequest();
};
Also wie gesagt, ich möchte offline eine XML-Datei in Javascript weiterbehandeln.
Vielen Dank im Voraus,
rohrspecht