maximebf / atomik

Micro framework for PHP 5.3+ [UNMAINTAINED]
MIT License
46 stars 18 forks source link

Ajax plugin doesn't exist anymore ? #29

Closed neovea closed 10 years ago

neovea commented 10 years ago

Hi there, I'm discovering atomik for the first time. I saw that there was an ajax plugin. But seems like it's not available anymore. Is there some kind of ajax handler ? I'm used to do some ajax, but here, I'm a bit in trouble.

maximebf commented 10 years ago

You don't need the Ajax plugin to do ajax. This plugin was just some helpers for a specific usage.

To do ajax, create a normal action in your actions folder and call it from js. Example app/actions/hello.php:

header('content-type', 'application/json');
echo json_encode(array('message' => 'hello world'));

In your javascript file using jquery:

$.getJSON('/hello', function(data) {
   alert(data.message);
});