Last active
December 15, 2015 16:39
-
-
Save alfredbez/5291034 to your computer and use it in GitHub Desktop.
JavaScript: AJAX check for subfolder
This file contains hidden or 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
/* | |
Skript prüft, ob Typo3 auf der jeweiligen Seite verfügbar ist, indem es einen Request an http://seitenname/typo3/index.php sendet und den zurückgegebenen Statuscode prüft. | |
Da es in einem Firefox Add-On laufen soll, wurde es für den Firefox entwickelt. Läuft aber genauso auch in Chrome. | |
*/ | |
var http_request = false; | |
function checkTypo3(){ | |
http_request = false; | |
if (window.XMLHttpRequest) { | |
http_request = new XMLHttpRequest(); | |
if (http_request.overrideMimeType) { | |
http_request.overrideMimeType('text/xml'); | |
} | |
} | |
http_request.onreadystatechange = checkStatus; | |
http_request.open('GET', 'http://' + window.location.host + '/typo3/index.php', true); | |
http_request.send(null); | |
} | |
function checkStatus() { | |
if (http_request.readyState == 4) { | |
if (http_request.status == 200) { | |
console.log('yep'); | |
} else { | |
console.log('nope'); | |
} | |
} | |
} | |
checkTypo3(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment