Load xml file in a directory using javascript

后端 未结 3 780
一个人的身影
一个人的身影 2020-12-21 16:31

I want to load a xml file using the javascript. I use the following code to load the xml file. The below coding loads the xml file when it is in the same folder.

<         


        
相关标签:
3条回答
  • 2020-12-21 16:55

    Unfortunately, you can't access local files through AJAX.

    You could try the HTML5 file access API, if you want.

    0 讨论(0)
  • 2020-12-21 16:59

    I dont think it can be loaded use this link it is useful for xml file loading

    Load xml

    0 讨论(0)
  • 2020-12-21 17:00

    Despite its name, XMLHttpRequest can be used for non-HTTP requests.
    The following should work

    xmlhttp.open("GET",'file:///C:/xml/dineshkani.xml',false);
    

    The result status is 0 for success instead of 200. This is because the file and ftp schemes do not use HTTP result codes.

    EDIT: However, some browsers, including Google Chrome disable this by default. It has to be enabled by starting Chrome with --allow-file-access. So if you are looking for a cross-browser solution, you should put the XML in your server directory.

    HTML5 file api does not let you access the entire filesystem you get a sandboxed directory to work with. Link

    Reference: MDN Page

    0 讨论(0)
提交回复
热议问题