It turned out the problem was that I was submitting the ajax request using the POST method but not actually sending any post data. For example:
$.ajax({
type: "POST",
url: "index.php?action=foo",
success: function(msg){
// ...
}
});
Changing it to a GET sorted out the problem.