# Ajax Error Response

**URL:** <https://www.ruby-forum.com/t/ajax-error-response/167324>\
**Category:** Rails\
**Created:** [May 6, 2009, 6:35pm UTC](https://www.ruby-forum.com/t/ajax-error-response/167324 "2009-05-06T18:35:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 6, 2009, 6:35pm UTC](https://www.ruby-forum.com/t/ajax-error-response/167324/1 "2009-05-06T18:35:11Z")

</div>

When my controller renders js along with a status other than 200, the  
js is not executed.

So

```
render :status => 400, :js => %{"alert('Error!')"}

```

Will not do anything, but

render :status =\> 200, :js =\> %{“alert(‘Error!’)”}

Will work just fine.

I can understand the reasoning since an error has occurred, but  
shouldn’t it be an option somewhere to have it eval the  
request.responseText? For now I am doing it in the :failure callback,  
I was just wondering if I was missing a more elegant solution.

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 6, 2009, 7:16pm UTC](https://www.ruby-forum.com/t/ajax-error-response/167324/2 "2009-05-06T19:16:51Z")

</div>

On May 6, 5:33 pm, TomRossi7 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

Is the content type getting set appropriately ?

Fred
