Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


JQuery and cfquery

Posted on 2013-12-02
Medium Priority
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 53

Assisted Solution

_agx_ earned 1336 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 664 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 53

Accepted Solution

_agx_ earned 1336 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

Independent Software Vendors: 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…
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 …
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

572 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