Solved

JQuery and cfquery

Posted on 2013-12-02
5
424 Views
Last Modified: 2013-12-10
I current have a page where I load an query when page load, and it generate a table of content. Current I have a pagination system that will make an AJAX call to the DB and return a query with the start row and end row.

Now my question is, is it better to load all the data from the query in an array, json or any other format and use AJAX to query that result set and not make the call to the DB anymore?
0
Comment
Question by:Medrise
  • 2
  • 2
5 Comments
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 334 total points
ID: 39691468
All depends on how much data you're loading. Pulling everything at once saves trips to the db, but the browser still has to parse it all and trying to parse a LOT of data can cause a browser freeze or get bogged down. If it's a small amount of data,it doesn't make much difference. Either way is fine.  However, once you move beyond that it's typically better to pull a page of data (10,20,50 records..) at a time to get the best balance of browser and server performance.
0
 

Assisted Solution

by:Medrise
Medrise earned 0 total points
ID: 39691528
_agx_ Thanks for the reply... It will depend on the user, some user will have a few records (10 to 50) and some may have 100 to 1000 records...

I guess I will keep like I have right now.  I have a stored procedure that takes a start row and end row... I guess it would be better to keep like that.
0
 
LVL 16

Assisted Solution

by:Gurpreet Singh Randhawa
Gurpreet Singh Randhawa earned 166 total points
ID: 39691793
Well for that such of work, I would prefer DataTables Jquery Plugin, server side code very easy and configurable to use

2. You can either use cfgrid to have such functionality where data comes in chunks and it does not freeze the browser anywhere

DataTables is more better as data comes in JSON format from backend and easy to display on screen

as AX Pointed out, loading much data will freeze the browsers and may not be a viable solution to work

if you have very little data i just suggestgo by the cfdiv way, the below post will help

http://www.raymondcamden.com/index.cfm/2008/12/14/Ask-a-Jedi-Simple-ColdFusion-8-Ajax-Pagination
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 334 total points
ID: 39692782
(Edit)

@Medrise - Yeah, if the number of records is potentially unlimited, then sticking with db side pagination is better. If you pull all the data across into the browser, it might work swimmingly for some users (10-50 records) but terrible (or not all) for others with more records.  (Side note, the ExtJS site is a good example of too much javascript activity IMO. It works on one of my computers ok, but frequently freezes the browser on another due to too much javascript activity). Sticking w/db pagination will provide good balance of consistency and performance on both the db and browser side for all users.
0
 

Author Closing Comment

by:Medrise
ID: 39708053
Thanks for all the info...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question