0

I am trying to run the basic demo "ajax demo" as seen below however not loading the file, the load icon on the page just keeps on churning.

    // ajax demo
    $('#ajax').jstree({
        'core' : {
            'data' : {
                "url" : "./root.json",
                "dataType" : "json" // needed only if you do not supply JSON headers
            }
        }
    });

Can somebody tell me what I need to do to make it work?

Also the lazy demo was not working either and I had the thought of mine to change the address from www.jstree.com/fiddle/?lazy to https://www.jstree.com/fiddle/?lazy is that a network/firewall issue?

NB: Both the local file and the server file are identical. I swear I have not changed anything in the Index.html files other than the references to jQuery and (which I am using a local downloaded version) and jsTree (as I moved the files out of the zip download to my project and I used a slight refined folder structure). And all other demo's in the index.html file are working. I have a separate folder called Demo hanging off the project root folder and it contains only the index.html and the root.json file. So is ./root.json the wrong path??

Glen
  • 802
  • 1
  • 11
  • 27
  • Yes running thru visual studio debug mode local server, added to an existing MVC c# asp.net project – Glen Aug 07 '15 at 11:26
  • For security reasons, you cannot access local files via ajax. See http://stackoverflow.com/questions/16683600/couldnt-ajax-local-file-from-local-html-page – mccannf Aug 07 '15 at 19:16

2 Answers2

0

If you are accessing the demo using a web server you should be fine - take a look at the dev tools in your browser - Net panel - you should be able to see what happens to that request.

As for the fiddle URL - that exists only for jsFiddle demos. Anyway, the problem you are having is caused by jstree.com switching to HTTPS (since last week). I will update the demos.

vakata
  • 3,726
  • 1
  • 17
  • 31
  • What do you mean by fine. I down loaded ver. 3.2.0 and the local version still does not work and the external version for that matter does not work either even with or without the "https:..." appended and you have not explained this clearly either. I am leaning towards @mccannf answer for the local version however quietly to myself I am saying just cannot understand why a link to an external file is less secure than a local file - a file is a file either way. Can somebody please explain. – Glen Aug 11 '15 at 04:17
  • I now have to retract my comment appending "https:" to the lazy demo url as it is actually working - must have been a network hiccup. I would have thought a path like "./root.json" was a server side reference so cannot see it is any different to the lazy demo url??!! – Glen Aug 11 '15 at 05:09
  • Please read carefully - I said exactly what @mccannf said: "If you are accessing the demo using a WEB SERVER you should be fine" - you should be testing AJAX demos using a web server. – vakata Aug 11 '15 at 05:53
  • So are you saying I need to download IIS 8.0 Express version for local testing purposes because the server thru which visual studio runs on is not a real web-server? I do not want to install a full IIS server on my work laptop do I or do I?. It is too hard basket to send my files to the administrator at work every five seconds while I writing experimental code. – Glen Aug 11 '15 at 06:23
  • Once again - if you are having AJAX problems - just take a look at the NET panel in your dev tools - see what happens to the request. Also make sure the URL in the browser starts with "http", not "file". I can assure you the demos work, there is something wrong with your setup. – vakata Aug 11 '15 at 07:29
0

I added the following to the bottom of my Web.Config and it works (so thanks to Allow loading of JSON files in Visual Studio Express 2013 for Web):

<system.webServer>
    <staticContent>
        <mimeMap fileExtension=".json" mimeType="application/json" />
    </staticContent>
</system.webServer>

Do not know why but it does! No need for WAMP or using a real web-server (IIS) the default web-server that comes with VS 2013 is enough (I assume this is an express version anyhow!?).

Community
  • 1
  • 1
Glen
  • 802
  • 1
  • 11
  • 27