javascript - jQuery: determine the [server's] Document Root -
in php can document root by: $_server['document_root']
. ej:
php
<?php $root = $_server['document_root']; $path = '/example/directory/'; $file = 'some-file.html'; include( $root . $path . $file ); ...etc ?>
how can value of $_server['document_root']
in jquery/javascript?
jquery
//example: var root = ????; var path = 'example/directory/'; var file = 'some-file.txt'; $("#example").load( root + path + file );
notes: whenever work on directories, on html page, "base" directory becomes directory of current file. ej, www.ejample.com/documents/examples/this-ex.html
. if call $("#example").load( path + file )
request documents/examples/ + example/directory
. said, it's not question server-side stuff. getting correct (and automatic) directory position
are looking document.location.hostname
?
var root = document.location.hostname; $("#example").load( root + path + file );
Comments
Post a Comment