4

I am asking this question again. I have this piece of code that loads a jsTree based on an XML file:

$("#div").jstree({
    "xml_data" : {
        "ajax" : {
            "url": "http://192.168.101.1/xml/jstree.xml"
        },
        "xsl" : "nest"
    },
    "plugins" : ["themes", "xml_data", "ui","types"]

When the file is on the same server as my script, it works. My tree loads.

"url": "jstree.xml"  

But when I do this:

"url": "http://192.168.101.1/xml/jstree.xml" 

I keep getting that infinite loading on the page. It is the same XML file and I can defitely access that XML manually when entered into my browser.

Anybody has seen this issue with jsTree? Is there a workaround?

dda
  • 6,030
  • 2
  • 25
  • 34
user1471980
  • 10,127
  • 48
  • 136
  • 235
  • 1
    Duplicate posts are discouraged: http://stackoverflow.com/questions/11957646/building-jstree-menu-based-on-xml Please provide a fiddle on the previous post. – MMeah Aug 15 '12 at 22:09
  • @MMeah, I cannot use jsfiddle from work. My question is very simple. Is it possible to do url: "http//data.xml" file within jstree plugin. I dont see any reference to it. I tried to do it and not working. – user1471980 Aug 20 '12 at 12:55
  • What is the error you are getting? Javascript error? Where is your xml lying when not on the server? Could it be a crossdomain issue? – mahatmanich Aug 22 '12 at 12:59
  • @mahatmanich looks like a cross domain issue, I dont know how to get around it. – user1471980 Aug 22 '12 at 13:57

2 Answers2

0

I resolve the issue by creating an server side script and calling the script file within my jquery. It works well.

user1471980
  • 10,127
  • 48
  • 136
  • 235
0

Pretty sure it's a cross domain restriction. You can't get XML cross domain. So work around is either a server side proxy solution for example

<?php readfile($_GET['url']) ?>

more details here

Or use yahoo pipes to convert your remote xml data into jsonp. Looking at the jstree docs it seems you can pass a jquery ajax object which hopefully could be one that's setup to do jsonp. Or manually get a jsonp response and pass it in to jstree as a json object.

Community
  • 1
  • 1
Keegan 82
  • 394
  • 2
  • 11