I am trying to consolidate all my javascript ajax calls into a Javascript Revealing Module. However there is 1 global javascript property called RootPath which is hard coded into the View page with an inpage script tag using:
var RootPath = '@Url.Content("~/")';
In a separate .js file I am creating calls to fetch JSON from my server side.
var dataService = function () {
var url = RootPath + "API/GetData",
getData = function () {
return $.getJSON(url);
};
return {
getData: getData
};
}();
Issue is that inside the Javascript object this global RootPath is undefined. How can I get this global property inside my object?