JQuery and cfquery

Posted on 2013-12-02
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?
Question by:Medrise
  • 2
  • 2
LVL 52

Assisted Solution

_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.

Assisted Solution

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.
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
LVL 52

Accepted Solution

_agx_ earned 334 total points
ID: 39692782

@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.

Author Closing Comment

ID: 39708053
Thanks for all the info...

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Detect which div element is visible? ***Javascript Only solution*** 4 21
Asp in script 6 39
Asp in server side with Mssql Server 7 4 27
Change to file doesn't show up 16 54
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

832 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