开发者

Javascript parse xml from local file

    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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜