treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Problems pointing to files on my server

  • I'm having some difficulty pointing to one of my js files on my server.

    I have a pretty standard set up,

    • index.html
    • js folder
    • css folder

    The difficulty is i have another folder called

    • 6_toggle

    Within this folder i have six html files named 1.html,** 2.html, etc. I need these individual files to point to a file in my js folder

    I thought it would be,

      <script src="../../js/view.min.js?auto"></script> 
    

    I've also tried,

      <script src="../js/view.min.js?auto"></script>
    

    But it doesn't seem to work.

    Would anyone have any ideas on how to fix this?ix this?

  • That last go around should have worked, is there a way we could see the directories?

  • If possible (and it usually is, unless this is for a code package you intend to distribute), I'd recommend using root-relative URLs instead:

    /js/view.min.js?auto

  • @matt_sanford Sure, here's a link to the site

    @traq sorry but i'm not sure what you mean.

  • @CameronDuthie

    @traq is basically saying use URL's that are relative to the root of you website folder, so instead of linking to your js file like this;

    ../js/view.min.js?auto
    

    Link to it like this;

    /js/view.min.js?auto
    

    Without the dots before the forward slash...

  • @Watson90 Hey man, thanks responding but i can't seem to see the code you've posted.

  • It's because I put src='path-to-file', I don't think it likes it when you do that.

  • @CameronDuthie - whis is the script path ending in '?auto' shouldn't it just be 'view.min.js'?

  • @Watson90 It can be both. It's a jQuery plugin developed by Rogie King and it says the quickest and simplest way to get it up and running is to add it with the ?auto at the end.

    Just tried it without the dots and still nothing.

    Am i right in thinking i need to reference this script in my index.html and in each html file in my 6_toggle folder?

  • This is the latest.

    It works perfectly here,

    But once it get's pulled into the index.html it doesn't want to work.

    So strange and i'm officially out of ideas...

  • How does it get "pulled into the index.html" ?

  • ...and what is it supposed to do?

  • @pmac627 The files in the 6_toggle folder get pulled through by jQuery.

    @Paulie_D It's supposed display as a lightbox effect there's an example of it here

    And it works perfectly in their individual files, http://orchidaberdeen.com/6_toggle/1.html

    but when the 1.html, 2.html, etc get called through into index.html it doesn't want to work.

    It get's pulled through for the gallery section, http://orchidaberdeen.com/#gallery

    any thoughts or suggestions would be greatly appreciated.

  • Then I'm forced to think that the way you are bringing in the content it is fundamentally inconsistent with what the JS actually does.

    Of course, I know nothing of JS.

  • Would pulling the files via jQuery trigger the browser to request the js files at all? I don't know enough about jQuery ajax calls to know. However, if it is requesting the js files when you use jQuery to request the 1.html, I would guess it is then looking for the JS file relative to where you pulled the file to, not from where the file actually sits. Try absolute links to the js files.

  • @Paulie_D @pmac627 Thanks for the comments guys.

    I've tried the absolute links but still nothing.

    It's a strange one. Any other thoughts?

  • Then I think that when you pull in the 1.html via jQuery, the browser is not then going out and searching for the scripts. That's the only guess I have. But again, I don't quite know how jQuery operates with .ajax().

    For the sake of ruling out my theory, try embedding the scripts you need in a script tag within 1.html and see if that works.

  • @pmac627 the script files are already embedded into the 1.html file which i believe is why the work when viewed on their own e.g http://orchidaberdeen.com/6_toggle/1.html

    But when viewing in the index.html the js doesn't seem to get pulled through with the rest of the file.

    I've also got the script file referenced in the index.html as i thought it might get picked up from there but it still doesn't like it.

  • I beginning to wonder if it's got something to do with the fact that i'm using jQuery to pull through another piece of jQuery?