Ajax errors in safari

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.

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

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/

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


Timothy J.