This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSON with Ajax.

 
pawan chopra
Ranch Hand
Posts: 417
jQuery Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a JsonArray of JSONObjects each object is basically filled with a node of XML. so for example:

JSONObject a = new JSONObject(); will have following properties id, parentId and name. Now I am creating a json array of these JSONObjects and sending it in request object. In my jsp using javascript I am iterating through that JSONArray and creating a javascript custom object which is basically used to display a tree structure on jsp page as shown in the attachment. Now If the length of json array is quite big, let us say it contains 1000 JSONObjects in that case my script takes alot of time and even I get error on the browser saying that "Script is taking alot of time do you want to continue?". Now to recover this problem I was thinking of using AJAX. So What I was thinking that suppose as shown in the attachment when user will click on Node 1 to open it ajax will make an asynchronous call to server's method by passing id of Node 1 and fetch all of it's children(as each node has it's parent's id) in a json array and then iterate through that array and create javascript custom objects and display them under tree. Is this idea correct? If yes can anyone suggest me how much time this will take to perform above action? And if no then suggest me some ideas to perform the above task.
tree.jpg
tree structure to be displayed
[Thumbnail for tree.jpg]
 
pawan chopra
Ranch Hand
Posts: 417
jQuery Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any body please help on this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic