# How to set up Ajax.Request, so that format.json block is executed?

**URL:** <https://www.ruby-forum.com/t/how-to-set-up-ajax-request-so-that-format-json-block-is-executed/158121>\
**Category:** Rails\
**Created:** [January 19, 2009, 3:21pm UTC](https://www.ruby-forum.com/t/how-to-set-up-ajax-request-so-that-format-json-block-is-executed/158121 "2009-01-19T15:21:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [January 19, 2009, 3:21pm UTC](https://www.ruby-forum.com/t/how-to-set-up-ajax-request-so-that-format-json-block-is-executed/158121/1 "2009-01-19T15:21:54Z")

</div>

Hi,

I’ve got format.js block in my code that returns some RJS.

I’m trying to do edit-in-place using RESTful approach and I’ve added  
format.json block to the update action, but I can’t figure out how to  
setup Ajax.Request, so this format.json block is actually executed.

I’ve tried adding contentType: “text/x-json” (or “application/json”)  
to Ajax.Request options, but I’m getting 404 errors. I’m using Rails  
2.1.2.

Cheers,  
Szymek
