ASP.NET MVC resolve urls in javascript

后端 未结 4 1226
执笔经年
执笔经年 2020-12-25 08:11

I am loading up some content via jQuery.load(\'/Business/Tags\'), which works well when using my local webserver. But when using iis this does not resolve correctly. I hav

4条回答
  •  暖寄归人
    2020-12-25 08:32

    I ran into this exact problem with my JavaScript. Since my JavaScript was also in a separate file which was included in my Master Page, I couldn't use ResolveUrl in my case.

    Here's how I solved it in my case. I included the following JavaScript in my head tag in my Master Page at the top:

    
    

    I'm setting a global variable that's accessible to all my JavaScript files called baseUrl.

    Your code would then become:

    jQuery.load(baseUrl + '/Business/Tags');
    

提交回复
热议问题