Hello,,
I have a page that tracks an order and returns a json with the result from a database. I created a form on another page and would like to post the tracking number by jquery ajax. I always get a CSRF error. My code is like this:
<script>
var csrf = "${ctx.getAttribute('csrf')!''}";
var mgnlModelExecutionUUID = "${content.@id}";
var trackingNumber = "1234";
var jqxhr = $.post( "track-order.html", {
trackingNumber : trackingNumber ,
csrf:csrf,
mgnlModelExecutionUUID:mgnlModelExecutionUUID, }, function() {
alert( "success" );
})
.fail(function() {
alert( "error" );
})
</script>
The same code works if I try a GET request but with POST I always get a csrf error. I know I can disable the csrf filter but why doesn't it work?
Cheers