# Rails partials violate javascripts "same origin policy"?

**URL:** <https://www.ruby-forum.com/t/rails-partials-violate-javascripts-same-origin-policy/191970>\
**Category:** Rails\
**Created:** [July 21, 2010, 2:16pm UTC](https://www.ruby-forum.com/t/rails-partials-violate-javascripts-same-origin-policy/191970 "2010-07-21T14:16:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brandentanga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ec9cab/32.png) [@brandentanga](https://www.ruby-forum.com/u/brandentanga)\
**Post date:** [July 21, 2010, 2:16pm UTC](https://www.ruby-forum.com/t/rails-partials-violate-javascripts-same-origin-policy/191970/1 "2010-07-21T14:16:40Z")

</div>

Hello,

In my rails application.html.erb, I have in javascript, an ajax post  
call defined in a dom element’s click method. This ajax call works fine  
whenever I’m at a view that is a standard render. However, whenever I’m  
at anything that is rendered using a rails partial, I get a 405 “method  
not allowed” error on that ajax post. All my googling points to 405  
errors commonly being caused by violating a brower’s “same origin  
policy” for javascript requests.

Does doing an ajax request from a rails partial really cause a “same  
origin policy” violation? If so, why?

---

<div class="post-metadata">

**Author:** ![brandentanga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ec9cab/32.png) [@brandentanga](https://www.ruby-forum.com/u/brandentanga)\
**Post date:** [July 21, 2010, 3:31pm UTC](https://www.ruby-forum.com/t/rails-partials-violate-javascripts-same-origin-policy/191970/2 "2010-07-21T15:31:47Z")

</div>

On Jul 21, 1:16 pm, Branden T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Does doing an ajax request from a rails partial really cause a “same  
> origin policy” violation? If so, why?

if you try and break the same origin policy you shouldn’t get a 405  
error - the request just doesn’t get made. Method not allowed means  
that the method of the http request (GET, POST etc…) isn’t one  
allowed by the server for that URI

Fred

---

<div class="post-metadata">

**Author:** ![brandentanga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ec9cab/32.png) [@brandentanga](https://www.ruby-forum.com/u/brandentanga)\
**Post date:** [July 22, 2010, 7:23am UTC](https://www.ruby-forum.com/t/rails-partials-violate-javascripts-same-origin-policy/191970/3 "2010-07-22T07:23:23Z")

</div>

Frederick C. wrote:

> On Jul 21, 1:16ï¿½pm, Branden T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Does doing an ajax request from a rails partial really cause a “same  
> > origin policy” violation? If so, why?
> 
> if you try and break the same origin policy you shouldn’t get a 405  
> error - the request just doesn’t get made. Method not allowed means  
> that the method of the http request (GET, POST etc…) isn’t one  
> allowed by the server for that URI
> 
> Fred

Hello,

Would you have any pointers as to how I could research this further? Why  
would mongrel allow me to do an ajax post to /cart from /users, but the  
doing an ajax post to /cart from /users/new is not allowed?
