What is the jQuery equivalent of $_SERVER[PHP_SELF]
?
I need it so I can insert it into a jQuery function
The jQuery is being called from inside the header
For example I'm trying make a request. This can come from multiple domains hence the need to set it dynamically.
$(".class").load( jQuery equivalent $_SERVER[PHP_SELF] "?page=" + pageNumberID + "&ipp=4" etc);
Use the properties of the window.location
object:
$(".class").load(window.location.pathname + "?page=" + pageNumberID + "&ipp=4" etc);
You want the name of the JavaScript file you're currently in? It doesn't exist.
Best you can do is window.location.href
which gives you the (full) URL of the page you're on.
What you could consider is a serverside script that wraps all your JavaScript files like:
files.add(<?php echo json_encode($filename);?>, function () {
<?php echo $filecontents;?>
});
This allows your to load JavaScript files as modules or 'widgets'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With