0

So I have a WordPress theme Laid Out like this:

wp-content/themes/themename/

and I'm loading javascript that exists in:

wp-content/themes/themename/library/js/script.js

my issue is I have a call in script.js that does this:

$("#message").load('text.html');

With text.html also in the js folder mentioned above, but text.html is not being loaded.

script.js is included by head.php in the wp-content/themes/themename/ folder. I tried placing the file there, and it doesn't work.

The onlything that seems to work is if the put the url http://www.domain.com/wp-content/themes/themename/text.html in load as follows:

$("#message").load('http://www.domain.com/wp-content/themes/themename/text.html')

Is it possible to load() the file with a path and not a full domain? The jQuery doc indicates that it is, however I just can't get it to work.

NotaGuruAtAll
  • 443
  • 3
  • 18
  • 2
    you need to load it relative to the current page, not the script. therefore, if the user is currently viewing `http://domain.com/index.php`, you'll have to reference it from the root. – Kevin B Jul 08 '14 at 20:30
  • Ah so I solved this on my own. You don't have to use http://... full url, your first slash will be relative to domain. So in my case: $("#message").load('/wp-content/themes/themename/text.html/text.html'); Is the equivalent while allowing the code to work agnostic to the domain. – NotaGuruAtAll Jul 08 '14 at 20:34
  • correct, as long as that path remains correct. – Kevin B Jul 08 '14 at 20:35
  • Thanks Kevin couldn't have solved it without that perceptual fix. :D – NotaGuruAtAll Jul 08 '14 at 20:36

0 Answers0