You forgot the prefix "th". your template should look like this:
<meta id="_csrf" name="_csrf" th:content="${_csrf.token}"/>
<meta id="_csrf_header" name="_csrf_header" th:content="${_csrf.headerName}"/>
and your ajax call:
var token = $('#_csrf').attr('content');
var header = $('#_csrf_header').attr('content');
$.ajax({
type: "POST",
url: url,
beforeSend: function(xhr) {
xhr.setRequestHeader(header, token);
},
success: function(data, textStatus, jqXHR) {
alert(status);
},
error: function(request, status, error) {
alert(status);
}
});