Page 1 of 1

Best way to load data and filters with AJAX

Posted: Wed Nov 21, 2007 1:38 am
by Stryks
Hi all,

I have some data I am loading into a table for display. I have the table set up with CSS to show a fixed header and allow scrolling through the results in a fixed sized table.

I need to have 3 chained dropdowns which will re-display the data matching the selected criteria. I also have a text box for freetext searching. At the moment I am using prototype to load a script which just outputs the returned data ...

Code: Select all

<body onload="new Ajax.Updater('chartBox', 'includes/ajax/tbl_nmi.php', { method: 'get' });">
I have set up a text box with a similar call with parameters to pass the search text to the table, and that works fine.

My problem comes with the chained selects (and I have already read the tutorial thread on this). I understand the concept, but what I'm wondering is what is the best way to return that html output, alongside the new data for the dropdowns?

Should I make a second ajax call? Seems a waste as the data is already being loaded for the table .... it's mean another load for the db-wrapper and a requery.

Or maybe I should not use the Ajax.Updater and go for the more complex method. This is my first time out with AJAX so I'm not sure there is a way to do this. I thought maybe XML or JSON and just sending the table in that. I dont know if this is barking up the wrong tree or not.

Any advice here guys? Thanks

Posted: Wed Nov 21, 2007 1:56 am
by feyd
I'm not sure how this applies to PHP. Can you explain?

Posted: Wed Nov 21, 2007 2:08 am
by Stryks
Sorry, wrong board.

Move please.