ajax - Chaning root of url load to javascript file? -


so when loading scripts or images .html file uses current location root of url call functions. when loading in external javascript file so:

<script type="text/javascript" src="external_java.js"></script> 

anything gets called javascript file above use .html's location on server rather .js file's location. there way change this?

that way when calling on xml file use .js location root of call?

$.ajax({     type: "get",     url: ../template/file.xml,     datatype: "xml",     success: function(xml) {         /*do here*/            }        }); 

you can absolute src of script files looking in document.scripts:

so if know first script load on page src="external_java.js", checking document.scripts[0].src give absolute path file.

from there i'd replace file name nothing in got src , have absolute root path... eg:

var root = document.scripts[0].src.replace("external_java.js", ""); 

and there can append/prepend paths you're trying call.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -