AJAX modals with Bootstrap 3

Bootstrap 3 provides support for loading content into a modal via ajax. Like so —

<button href="remotePage.php" data-toggle="modal" data-target="#myModal">Fetch</button>

However, one annoyance is that once it loads a page you can no longer request a different page – the request to /remotePage.php won’t be sent again. This is a problem if you have various buttons that request different information.

You can “reset” it after a modal is closed by adding this code to your page (in script tags) —

$('body').on('hidden.bs.modal', '.modal', function () {
$(this).removeData('bs.modal');
});

Ultimate do “not cache this page” for PHP

Below is the ultimate set of headers to send from PHP to ensure a page is not cached —

header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

Contempt WordPress Theme

I’ve uploaded the Contempt WordPress theme to github. You may know of it as having been one of the original WordPress.com themes (I believe it’s still in the top 50), but sadly it needs a new caretaker quite badly.

Originally made by me 5+ years ago, it’s since had some updates, but needs lots of work. I’ve made it public as the old locations have been lost.

Feel free to use it, modify it, etc.