Created
May 19, 2017 20:18
-
-
Save calexandrepcjr/c263ff735b711df1cbaa19d911c8222b to your computer and use it in GitHub Desktop.
A different way to work urls into ajax calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.pathname = window.location.pathname.split('/'); | |
//Normally in the dev environment the project will be inside a path into htdocs dir | |
if (window.location.host == 'localhost'){ | |
this.subDirs = this.pathname.length - 3; | |
} else { | |
this.subDirs = this.pathname.length - 2; | |
} | |
this.baseUrl = '../'; | |
this.baseUrl = this.baseUrl.repeat(this.subDirs); | |
self.path = this.baseUrl + 'path or source that you want'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment