views:

534

answers:

1

Being new to Ajax, I would like to understand which data exchange format - JSON or XML - would be easier to work with while doing Ajax in Rails.

Do the various Rails helpers make one or the other format easier to deal with or does it depend on the context or does it not matter at all?

+3  A: 

As of writing, Rails uses Prototype as its default JavaScript framework. Prototype is agnostic regarding JSON or XML because its Ajax.Request object automatically evaluates either response format.

In addition, controllers in Rails will handle JSON or XML equally well using the respond_to method and ActiveRecord models automatically include both to_json and to_xml methods.

So it really comes down to personal preference, I'd say. They are both equally easy to work with.

John Topley
Thanks .
carson welsh