I have a Javascript function, where I want to call jQuery.Load() to load a file. How would I get ASP.Net to fill in the local server name, so that I can just give a relative path?
The reason for that is I can give the base, say "http://www.mydomain.com/", however I would like to be able to test locally and not have to publish on every single build. I just want to load a local file.
My first thought was just "/MyFolder/MyPage.aspx", but that did not work. I then thought of "~/MyFolder/MyPage.aspx", but that did not work either.
I figure it should be some sort of ASP.Net directive to prepend, just I am not sure what.
I wanted to give some code to show the actual use and what worked.
<head runat="server">
<script type="text/javascript">
// <![CDATA[
function DoPopupSignin()
{
var urlLoad = "http://" + window.location.host + '/Candiates/Login.aspx';
// Triggering bPopup when click event is fired
$('#popupSigninMaster').bPopup({
//modalClose: false,
//opacity: 0.6,
//positionStyle: 'fixed', //'fixed' or 'absolute'
content: 'iframe', //'iframe' or 'ajax'
contentContainer: '.content',
loadUrl: urlLoad, //Uses jQuery.load()
});
}
// ]]>
</script>
</head>
I am trying to get my jQuery Popup working loading the contents from another file. My code uses the free jQuery popup control that I found jQuery.bPopup.js.
In JavaScript as you are preparing your query, you can use window.location.host
.
var path = window.location.host + '/relative/path/file.ext';
$.load(path);