I want to make a ajax call using $.POST. But I am getting 403 error. But GET works perfectly fine. My code is:
var url = \"/xyz/abc/subscribe?name=\"+name;
$
If you look to CSRFilter source code, you will see that the filter is waiting for csrfToken on header or query parameter. In my configuration, the key "_csrf" was the right key in query parameter. So, I added this parameter in my post call.
var csrfCookie = getCsrfCookie();
alert(csrfCookie);
function getCsrfCookie()
{
var ret = "";
var tab = document.cookie.split(";");
if(tab.length>0){
var tab1 = tab[0].split("=");
if(tab1.length>1)
{
ret =tab1[1];
}
}
return ret;
}
$http.post('/testPost?_csrf='+csrfCookie).success(function (response) {
alert("post : "+response);
return response;
});
With this, it works for me.