Update CSRF filter for protecting Ajax post requests

One of the variants how to use it:
* Each view file that uses Ajax should include the field like this:
 <input name="csrf-token" type="hidden" value="<?php echo csrf_token();?>"/>
* A code for adding in a JavaScript file (using jQuery) before the Ajax post request:
$.ajaxSetup({
    headers: 
    {
         'X-CSRF-Token': $('input[name="csrf-token"]').val()
    }
});