$(document).ready(function () { var arr = window.location.href.split("/"); if (arr[3].indexOf('app') == 0) baseUrl = ''; else if (arr[3].indexOf('account') == 0) baseUrl = ''; else if (arr[3].indexOf('Certification') == 0) baseUrl = ''; else if (arr[3].indexOf('admin') == 0) baseUrl = ''; else baseUrl = '/' + arr[3]; //console.log('SetCulture.js', baseUrl); $("#setculture").click(function (event) { $.ajax({ type: 'POST', url: baseUrl+'/api/setculture/' + event.target.lastChild.value }).done(function () { location.reload(); }); }); });