jquery - Different URL path -


how set url in javascript (jquery) when deploy application in iis, please? in visual studio url works (without path):

url: '/street/details/', 

but in iis url correct

url: '**/utca**/street/details/'. 

i want modify urls in every js file automatically.

if you're using asp.net-mvc-5 shouldn't using any hardcoded paths.

you should using @html.action or @url.action or equivalents. allows move things @ / per-environment.

if must use paths directly, eg in .js file can't use server-side , don't want go hassle of passing url either parameter or data- attribute, easiest method set global (or namespaced) variable root path, eg place @ <head> of _layout.cshtml:

<script type='text/javascript'>     var mynamespace = mynamespace || {};      mynamespace.rootpath = '@url.content("~")'; </script> 

then script can use whereever needed, eg:

$.ajax({     url: mynamespace.rootpath + 'street/details/', 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -