In a file named job.js, there is code that works perfectly when run on localhost but results in a 404 error when run on an intranet server with an application name.
Job.updateJob = function () {
$.post('/Builder/ListJobItems', function (data) {
...
});
}
I wish I could use @Url.Action()
, but since this is a JavaScript (.js) file, it's not possible. I'm aware of the hack where data is added to the body element, but I prefer to keep this code decoupled from the DOM for architectural reasons. This code is meant for data acquisition and shouldn't have knowledge of the DOM.
If there was a way to parse window.location
, I would be open to it, but it needs to work universally. What frustrates me the most is that it seems like a common issue, yet there are no widely accepted solutions available. Are people just embedding all their JavaScript in Razor views now? Is modular code isolation becoming obsolete? It's hard to believe, but the lack of solutions makes me wonder.