Hey Samuel,
I wrote something super basic for this once, here is a basic extract:
PHP Code:
$json = "";
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "";
if ($action == "do_something") {
$data = do_some_action_that_returns_an_object();
//json encode your data
$json = json_encode($data);
}
header("Content-type: application/json");
print $json;
You just specify some parameters and then "do something" based on those parameters. You can then json_encode() your results and print them to have your data returned as a JSON result.
Please note that this is super super basic, and I haven't used this for anything other than some personal things, but if you simply want to test ajax functionality then it will do the trick.
P.S. if you're interested in testing AJAX functionality with jQuery, you might find that "Mockjax" will suffice: https://github.com/appendto/jquery-mockjax
Bookmarks