# CSRF protection not working with jquery ajax post request

**URL:** <https://www.ruby-forum.com/t/csrf-protection-not-working-with-jquery-ajax-post-request/194463>\
**Category:** Rails\
**Created:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/csrf-protection-not-working-with-jquery-ajax-post-request/194463 "2010-09-06T16:39:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a88e4f/32.png) [@Manos](https://www.ruby-forum.com/u/Manos)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/csrf-protection-not-working-with-jquery-ajax-post-request/194463/1 "2010-09-06T16:39:33Z")

</div>

Hallo,  
I want to test the csrf protection of my application but forgery  
protection is not working with jquery ajax request.  
I have used Unobtrusive Javascript with jquery  
I have removed the  
\<%= csrf\_meta\_tag %\>  
so that my application do not include authenticity token.  
In my view I have the following code

$(function () {  
$(’#alert’).click(function () {  
$.ajax({  
type: “POST”,  
data: ({ lo: 67, pi: 22 }),  
url: ‘/test/set’,

```
    });
})

```

});

I have also include in the application controller  
protect\_from\_forgery

and have set in development configuration  
config.action\_controller.consider\_all\_requests\_local = false

However the post command is completed successfully.  
Does anyone know why the protection is not working?

Thank you
