I am trying to get the site base url using javascript . I am using
var pathArray = window.location.pathname.split( '/' );
var baseURL = window.location.protocol + "//" + window.location.host + "/" + pathArray[1]+'/';
This is working for mysite.com/project1
but not for mysite.com
.
How can I check this for both the urls ? I have to send ajax request to the url.
Thanks in advance.