Update csrf filter for protecting ajax post requests

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