Jquery relative and absolute path
javascript, jquery, relative-path
Solution
The way JavaScript works it that it loads from the file it was called from and now the file it was written in.
In order to do what you need you need to supply the relative path from the current page you're viewing.
Example:
If current page is http://www.domain.com then you'll need to do:
$("#test").load("wp-content/includes/mytheme/index_loader.php");
If current page is http://www.domain.com/wp-content/index.php then you'll need to do:
$("#test").load("includes/mytheme/index_loader.php");
As a side note CSS is not the same way and CSS the relative path is based on the file it's written in.
Problem
I need determinate this path in jquery , actually i have one file called functions.js and inside of this one function for load url with jquery The problem it´s the js load in the index of website and the file really in subfolder ``` <script src="http://www.domain.com/wp-content/includes/themes/mytheme/js/functions.js"></script> ``` The js called in the index of website it´s into wp-content/includes/themes/mytheme/js And the load jquery call to : wp-content/includes/themes/mytheme/index_loader.php I can put the absolute path to index_loader.php in jquery , but my question it´s if it´s possible no use this and calculate the path into js file Actually : ``` $("#test").load("http://www.domain.com/wp-content/includes/mytheme/index_loader.php"); ``` It´s possible this or calculate inside jquery file ? - I try and no works ..... ``` $("#test").load("../index_loader.php"); ``` This it´s my problem really , thank´s regards