开发者

Javascript parse xml from local file

开发者 https://www.devze.com 2023-03-16 23:15 出处:网络
var xmlReq, xmlDoc; xmlReq = new XMLHttpRequest(); xmlReq.open(\"GET\", filename, false); //synchronous GET
    var xmlReq,
        xmlDoc;

    xmlReq = new XMLHttpRequest();
    xmlReq.open("GET", filename, false); //synchronous GET
    xmlReq.send(null);

    xmlDoc = xmlReq.responseXML;
    alert(xmlDoc);

I'm trying to use the above mentioned code to load an xml from the local filesystem. the variable filename is a relative path (../Gfx/Sprite/t开发者_StackOverflow中文版est_sprite.xml) and works both in local and when running the page from a web server. What makes this wierd, is that I can see that the xml file loads (using web inspector in safari), but the xmlReq.responseXML/xmlReq.responseText returns null...

What am I doing wrong here?


Webkit doesn't allow AJAX-requests on the local file-system.

0

精彩评论

暂无评论...
验证码 换一张
取 消