0

enter image description hereI am trying to create my JSTree using an XML file, here is the piece of code I am using so far :

$("#jsopen").jstree({  
    "xml_data" : {  
        "ajax" : {
            //"url": "jstree.xml" 
            "url": "file:///C://gexml/f1.xml"      
        },  
        "xsl" : "nest"
    },        
    "plugins" : ["themes", "xml_data", "ui","types"] 
});
<div id="jsopen" class="jsopen"></div> 
E.Sophia
  • 49
  • 1
  • 12
  • The major problem is because you're making an AJAX request to the local file system, which is not allowed in any browsers as a security restriction. For the request to work you need to use a webserver (either local or remote). Once you've got that setup you just need to verify the XML is in the correct format for the jsTree plugin to read – Rory McCrossan May 13 '16 at 09:45
  • Can I use something else instead of Ajax to be able to call the local file, it is a web application and I need to give the user the possibility to open a file – E.Sophia May 13 '16 at 09:52
  • AJAX is what you should be using, and will work - you just simply need to run your code on a server, not on your local file system. – Rory McCrossan May 13 '16 at 09:52
  • I am running it on the server even tried to replace the file:///... with the link http://@:8090/xml/pages/f1.xml still getting nothing – E.Sophia May 13 '16 at 09:56
  • In that case check the console for errors. – Rory McCrossan May 13 '16 at 09:58
  • console.error(); gives me nothing to output – E.Sophia May 13 '16 at 10:03
  • No I mean the actual console, press F12 to see it – Rory McCrossan May 13 '16 at 10:03
  • using Firebug I inserted the screenshot on the question – E.Sophia May 13 '16 at 10:07
  • What version of JStree are you using? I don't think the current version supports XML data any longer. If you have to start with XML data, you might want to just use another plugin to convert it to JSON data, which will then work with JStree. Have a look here: http://stackoverflow.com/questions/1773550/convert-xml-to-json-and-back-using-javascript – Adam May 13 '16 at 14:39

0 Answers0