# Ajax errors in safari

**URL:** <https://www.ruby-forum.com/t/ajax-errors-in-safari/64276>\
**Category:** Rails\
**Created:** [June 23, 2006, 6:07pm UTC](https://www.ruby-forum.com/t/ajax-errors-in-safari/64276 "2006-06-23T18:07:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhnsntmthy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jhnsntmthy](https://www.ruby-forum.com/u/jhnsntmthy)\
**Post date:** [June 23, 2006, 6:07pm UTC](https://www.ruby-forum.com/t/ajax-errors-in-safari/64276/1 "2006-06-23T18:07:32Z")

</div>

I am implementing some AJAX features into a web forum, and one feature  
works fine in Firefox and in IE, but it is choking in Safari. Safari  
will send the request fine and the data will be stored in the DB, but  
it is not responding correctly to the RJS that is being sent back.

Anybody notice issues with Safari parsing the javascript sent back to  
the browser?

–  
Timothy J.

---

<div class="post-metadata">

**Author:** ![jhnsntmthy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jhnsntmthy](https://www.ruby-forum.com/u/jhnsntmthy)\
**Post date:** [June 23, 2006, 10:45pm UTC](https://www.ruby-forum.com/t/ajax-errors-in-safari/64276/2 "2006-06-23T22:45:16Z")

</div>

Hi Timothy, I just dealt with this exact problem.

The issue seems to be that rails wraps rjs responses in a javascript  
try/catch block in development mode. Like this…

try {  
close\_lightbox();  
} catch (e) { alert(‘RJS error:\n\n’ + e.toString());  
alert(‘close\_lightbox();’); throw e }

Safari chokes on the try/catch and doesn’t run your code.

For me the solution was to set the following in development.rb:

config.action\_view.debug\_rjs = false

which will simplify the rjs response to…

close\_lightbox();

Hope this helps!  
\_\_

Simon Claret

---

<div class="post-metadata">

**Author:** ![jhnsntmthy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jhnsntmthy](https://www.ruby-forum.com/u/jhnsntmthy)\
**Post date:** [June 23, 2006, 11:16pm UTC](https://www.ruby-forum.com/t/ajax-errors-in-safari/64276/3 "2006-06-23T23:16:14Z")

</div>

On Jun 23, 2006, at 3:42 PM, simon claret wrote:

> Safari chokes on the try/catch and doesn’t run your code.  
> \_\_
> 
> > Anybody notice issues with Safari parsing the javascript sent  
> > back to  
> > the browser?

It’s possible this try/catch bug is fixed already in Webkit. If you  
feel like living on the edge, try downloading one of the nightly  
builds. See instructions here [1] on how to upgrade Safari to use it.

cr

[1] [http://webkit.opendarwin.org/](http://webkit.opendarwin.org/)

---

<div class="post-metadata">

**Author:** ![jhnsntmthy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@jhnsntmthy](https://www.ruby-forum.com/u/jhnsntmthy)\
**Post date:** [June 25, 2006, 7:22pm UTC](https://www.ruby-forum.com/t/ajax-errors-in-safari/64276/4 "2006-06-25T19:22:46Z")

</div>

Thanks Simon, That answered my question sufficiently. Stinks, but at  
least when I throw it into production the issues are gone.

–  
Timothy J.
