WordPress: create AJAX calendar

Working on one project, I got an idea to create a custom posts calendar which will be updated by ajax call.

First, I forked get_calendar() function. I copied the function to functions.php file and renamed to get_calendar_local().
I changed the view of the calendar and made it look as following:
custom_calendar
Left/right buttons are coded as following:

Then I added proper handling for left/right buttons in javascript:

I use Polylang for multilingual support and I needed to specify language in order to localize ajax request.
The following lines should be added to functions.php actions ‘wp_enqueue_scripts’.

The most interesting part – adding ajax function support to functions.php: