File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes JSON with Ajax. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JSON with Ajax." Watch "JSON with Ajax." New topic

JSON with Ajax.

pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 415

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.

[Thumbnail for tree.jpg]

Pawan Chopra
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 415

Can any body please help on this?
I agree. Here's the link:
subject: JSON with Ajax.
It's not a secret anymore!