5 ms·
For anyone interested, here's a bookmarklet to view the current page's HTTP status code (makes a new request): javascript:(function()%7Bjavascript%3A(funct
by notRobot 3y ago
For anyone interested, here's a bookmarklet to view the current page's HTTP status code (makes a new request):
javascript:(function()%7Bjavascript%3A(function()%20%7B%0A%20%20var%20xhr%20%3D%20new%20XMLHttpRequest()%3B%0A%20%20xhr.onreadystatechange%20%3D%20function()%20%7B%0A%20%20%20%20if%20(xhr.readyState%20%3D%3D%3D%204)%20%7B%0A%20%20%20%20%20%20alert('HTTP%20Status%20Code%3A%20'%20%2B%20xhr.status)%3B%0A%20%20%20%20%7D%0A%20%20%7D%3B%0A%20%20xhr.open('GET'%2C%20window.location.href%2C%20true)%3B%0A%20%20xhr.send()%3B%0A%7D)()%3B%7D)()%3B
- dtgriscom 3y agoFor suspicious types (including me): javascript:(function(){javascript:(function() { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { alert('HTTP Status Code: ' + xhr.status); } }; xhr.open('GET', window.location.href, true); xhr.send(); })();})();
- deleted 3y ago[deleted]
- sopooneo 3y agoAnd to recurse on more level: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequ...
- recursive 3y agoThis assumes a GET.
- mike503 3y agoAlso firing a second request would break restful behavior and could wind up really messing stuff up worse. Maybe it places an order twice? Who knows. Not a good idea.
- notRobot 3y agoIf reloading a page (which is what this is identical to) breaks your website, that's not on the user.
- notRobot 3y agoGET requests are not supposed to modify server state. https://stackoverflow.com/questions/45016234/what-is-idempotency-in-http-methods https://stackoverflow.com/questions/45016234/what-is-idempot... https://en.wikipedia.org/wiki/HTTP#Request_methods https://en.wikipedia.org/wiki/HTTP#Request_methods