Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   transmitting raw data vs. tree-structured data (http://www.velocityreviews.com/forums/t863198-transmitting-raw-data-vs-tree-structured-data.html)

Max You 06-16-2010 05:07 PM

transmitting raw data vs. tree-structured data
 
Hi, I'm trying to decide using one of two approaches getting
tree-structured data to users.

approach #1:
build the tree from raw data in rails model code, then transfer it via
AJAX in XML

approach #2:
transfer all raw data in XML form first, then use javascript to build
the tree.

The problem with approach #1 is that I'm currently stuck doing it.
Building the tree in model code is easy; but I'm having all sort of
problems transferring it. (I can't use hash.to_xml directly since each
key is an object, and using object.to_xml while building to tree results
in incorrect rendering)

The problem with approach #2 is I don't know if javascript is power
enough to handle "building a tree from xml, preferably using a hash that
can have associative arrays as keys", which is why I want to ask around
and post on this forum.

I'm new to both Rails and javascript.

Anyone has any ideas?
--
Posted via http://www.ruby-forum.com/.


Brian Candler 06-16-2010 05:52 PM

Re: transmitting raw data vs. tree-structured data
 
Max You wrote:
> Anyone has any ideas?


Use JSON.
--
Posted via http://www.ruby-forum.com/.


Max You 06-19-2010 09:06 PM

Re: transmitting raw data vs. tree-structured data
 
Thank you both for the replies. I ended up mandating all AJAX data
transfer to use JSON format, and it works very well. Additionally, it
turned out very easy to rewrite the stuff and add custom to_json methods
in rails.
--
Posted via http://www.ruby-forum.com/.



All times are GMT. The time now is 08:29 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57