{"id":11494,"date":"2016-06-08T14:55:55","date_gmt":"2016-06-08T19:55:55","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=11494"},"modified":"2016-06-08T15:19:00","modified_gmt":"2016-06-08T20:19:00","slug":"asp-net-mvc5-get-base-url-in-javascript","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=11494","title":{"rendered":"ASP.Net MVC5: Get Base URL in JavaScript"},"content":{"rendered":"<p>* Get base url<\/p>\n<pre lang=\"xml\">\r\n    <script type=\"text\/javascript\">\r\n        var baseUrl = '@Url.Content(\"~\")';\r\n    <\/script>\r\n\r\n<\/pre>\n<p>* Use it in ajax, for example:<\/p>\n<pre lang=\"xml\">\r\n$(document).ready(\r\n    function () {\r\n        var vm = new ViewModel();\r\n\r\n        $.ajax({\r\n            url: baseUrl + 'api\/menu\/',\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>* Get base url * Use it in ajax, for example: $(document).ready( function () { var vm = new ViewModel(); $.ajax({ url: baseUrl + &#8216;api\/menu\/&#8217;,<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[705,18],"tags":[706,707,496],"class_list":["post-11494","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-javascript","tag-asp-net","tag-baseurl","tag-javascript-2"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2Zo","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11494"}],"version-history":[{"count":3,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11494\/revisions"}],"predecessor-version":[{"id":11496,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11494\/revisions\/11496"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}