I am using purely javascript to access to certain web services built with Spring. when I tried to use an Ajax Post call to one of the services I encountered the issue with CSRF.
The Ajax call is the lines of:
var data = {'attribute1':'1','attribute2':'2'};
$.ajax({
type: "POST",
url: url,
data: data,
success: function(data)
{
if (typeof inputId !== 'undefined') {
$("#"+inputId).val(JSON.stringify(data));
}
console.log(JSON.stringify(data));
}
});
I have been searching the web, but all that I found is to update the backend (JSP, PHP) to populate the attribute "${_csrf.parameterName}" in the form. However, I am not using any backend, all the page is HTML and javascript only.