I have the following situation.
I developed my first MVC Asp.Net application. it runs on my server at the following adress
http://localhost:59441/
Pass @Url.Action("action","controller") to the javascript from the view. This will allow it to be update dynamically at run time.
There may be a function to get the root path also which you could use to initialize the root variables in the previous answers.