• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

When not to use Ajax?

 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

I am doing late hours in office because of AJAX. Well not exactly AJAX but becasue of the rendering of the page. So I wanted to know when to use Ajax.

This is my first AJAX module. I am using AJAX to render a data grid, basically a table inside a div. I thought it would be easy as I did a few simple excercises to get a feel. Well as far as AJAX's data fetching is concerned it's OK. The problem comes in when you need to render the response. The thing is you need to explicitly tell everything how it should be rendered. Rendering a whole table on fly is @#$@$@. Then as if it was not enough then you have different browser (mainly IE and non-IE) issues.

The good thing about it was that I learnt a lot about DOM. So does anyone has a list of do's and don'ts for AJAX usage?

And yeah as two posts won't let me win two books, appending a totally unrealated question here only .

How do I go about adding a checkbox through javascript with an onClick handler. One approach is to use the innerHTML property, and stuff in everything in there. Infact that's what I did but it didn't looked right to me. The whole table is rendered by using createElement so this innerHTML looks out of place. The other option was to use event handlers which sounded a bit scary.

[ April 12, 2007: Message edited by: Anupam Sinha ]
[ April 12, 2007: Message edited by: Anupam Sinha ]
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your first question is less a "when not to use Ajax" question, than a "how do I use Ajax effectively" question.

Have you considered using a JSP to format the table prior to sending it to the browser? I've used this tactic with great success.
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Bear.

What we are doing is as follows:

The whole table is created on the fly. The table head can be one of the two forms. The table body is that part that needs to be data to be dynamically populated. Secondly the table also changes dynamically. I mean the head the no. cols. changes dynamically.
 
author
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anupam,

Parsing XML documents on the client using DOM is no fun - I sympathise with you there.

You need structured data for the grid body, but if XML is causing problems, have you looked at JSON as an alternative? And, if you do decide to use XML, have you looked at XPath and XSLT as ways of simplifying the process? Chapter 2 deals with these issues, and gives examples of how XPath can take the pain out of XML handling.

Best,

Dave
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dave

Thanks for the reply. The first thing after your reply I noticed was your signature. You seem to be quite an authority on AJAX. Well thanks for the sympathy. I have my whole team's sympathy with me. Yeah I was told about XSLT to take away some of the pain of rendering the HTML but then again it would be a new thing to learn. Probably in the long run it would be good but now I am trying to put my project back in schedule. Let's see what this saturday (being in office) brings in for me.

Don't realy know much about JSON. Probably would explore it in my spare time.
[ April 13, 2007: Message edited by: Anupam Sinha ]
 
keep an eye out for scorpions and black widows. But the tiny ads are safe.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic