Question

AJAX to do Real Time DB Polls like Twitter's "Real Time Results" in Coldfusion

Asked by: andrewaiello

Hello All,
     I want to do something similar to the way twitter searches use AJAX to create the "Real-Time Results"..  It seems that the database is polled every 15 seconds or so and the number of new records is displayed to the user after each pull.  I am working on a Coldfusion 8 server with a MS SQL database and I need to implement something like this ASAP.  
     I posted a question similar to this earlier and an expert was assisting me; though he was indeed extremely helpful the thread got lost in the shuffle and I need some help with this ASAP.  I believe the solution will involve jquery javascript library (http://jquery.com), coldfusion components, cfajaxproxy to work with the cfcs, and the java setInterval() function.  
     I'm tight on time; can anyone illustrate some sample code for an implementation of the simplest version of this?  Hopefully I can then understand and adapt it to my needs.
     Thank you in advance!!

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-03 at 09:05:28ID24867839
Tags

AJAX

,

Coldfusion

,

MSSQL

,

Javascript

Topics

ColdFusion Application Server

,

Asynchronous Javascript and XML (AJAX)

,

MS SQL Server

Participating Experts
2
Points
500
Comments
42

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ColdFusion 7 and AJAX
    Does Coldfusion 7 have built in AJAX support? I'm trying to research how to implement AJAX into our form submissions.
  2. Getting started with AJAX
    I'd like to get started using AJAX with Coldfusion, there are a bunch of libraries available. I'm wondering if someone can recommend one of these (or an alternative) and give me a jump start. I kinda feel like this is choosing between VHS and Beta and I bet get started i...
  3. setInterval  calls AJAX function once then stops working
    The easiest is probably provide you with example scripts to explain my problem: 1. I have the following script located on a PHP page: <script language="javascript" type="text/javascript"> setInterval("ajaxpulse(brefresh.php?random=<?php ech...
  4. Coldfusion and AJAX
    I've never used AJAX before but I need to in a new project I'm working on. Can you suggest any good places to read about using AJAX with coldfusion and provide some help with getting AJAX set up. I tried using cfajax but could not get any of the examples to work. Not sure ...
  5. jquery setInterval function call + ajax & params
    HI There, I'm hoping that someone has run into this problem before. I want to use the setInterval function in jquery to make ajax call with parameters but i'm not sure of the syntax. I have a code snippet below, can someone help me correct it please? Sean - thanks in advan...
  6. Chained select box using Ajax, ColdFusion and DB
    Hello experts. I have found a working solution on this page:http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/Q_23902796.html?sfQueryTermInfo=1+ajax+chain+coldfus+select The question i have is how to make this work using a DB ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: SidFishesPosted on 2009-11-03 at 11:50:16ID: 25732775

i don't do jquery or use many of the builtin in cfajax functions but here's a basic concept for you using jsmx ajax engine from lalabird.com, a bit of js and a simple cfc you can fancy it up however you like and replace the function with a query. If you need to pass arguments to the cfc just use param

ie:

param = 'someid=' + documentGetElementById('somehiddeninputfield').value + 'someothercriteria' +  documentGetElementById('someotherhiddeninputfield').value;
            http('POST','http://website.com/util.cfc?method=getUpdate',getUpdate_response,param);       




dbrefresh.cfm

<script  type="text/javascript"  src="engine.js"></script>
<script type="text/javascript">

function init(){
            param = '';
            http('POST','http://website.com/util.cfc?method=getUpdate',getUpdate_response,param);       
            }
function getUpdate_response(obj){

var  existing = document.getElementById('updatePanel').innerHTML
var resp = obj.myid + obj.mytime

document.getElementById('updatePanel').innerHTML = existing + '<br>' + resp;
setTimeout("init()",15000);


}            
            
            </script>

<body onLoad="init()">
<div id="updatePanel">
Initial Text

</div>
</body>

util.cfc

<cfcomponent>
<cffunction name="getUPdate" returntype="struct" access="remote">
<cfset update = {myid = #createuuid()#,
                        mytime = #now()#}>
            <cfreturn update>
</cffunction>
</cfcomponent>



            

 

by: SidFishesPosted on 2009-11-03 at 11:59:51ID: 25732904

one quirky thing to watch

returned objects are always lower case

var resp = obj.myid + obj.mytime
and not

var resp = obj.myId + obj.myTime

 

by: andrewaielloPosted on 2009-11-03 at 13:07:31ID: 25733653

Thanks Sid,

     Good to see you again; thanks I will try to whip something up and see what happens.

 

by: azadisaryevPosted on 2009-11-04 at 06:46:31ID: 25739780

sorry it took me so long to get back to this that you even had to opened a new question...

attached is a working example (i.e. prrof of concept).

it uses a query stored in session scope, so make sure sessions are enabled in your application.

put all the files in same folder, remove .txt extensions from them (EE does not allow uploading .cfm files, even inside a zip archive...).
javascript code is commented, but do ask if something is unclear.

Azadi

  • index.cfm.txt
    • 4 KB

    main application page [remove .txt extension]

  • search.cfc.txt
    • 1 KB

    the cfc file [remove .txt extension]

  • query.cfm.txt
    • 645 bytes

    creates session query (cfinclude'd in index.cfm) [remove .txt extension]

 

by: andrewaielloPosted on 2009-11-04 at 07:38:23ID: 25740377

Thanks a lot azadisaryev; I'll give this a try now.  No worries; I understand that people get busy; I just had a tight deadline; thanks again!

 

by: andrewaielloPosted on 2009-11-04 at 11:49:50ID: 25743157

Thanks; I got the sample project working dandy, now I am just trying to apply it to my current project.  I'm having a little trouble modifying the query.cfm because my DB is already setup (and I'm not creating it at page launch with querynew as you are in this sample).  Basically I don't know how to associate session.qSearch with my prebuild DB instead of the one your creating here (or if its even necessary).

Still trying to figure it out on my own over here as well; thanks!

 

by: azadisaryevPosted on 2009-11-04 at 11:58:44ID: 25743258

>> Basically I don't know how to associate session.qSearch with my prebuild DB instead of the one your creating here (or if its even necessary).

it is not necessary - you can (and should) use your own query. and you do not need to put it in session scope either - that was just for my example to work without extra db setup.

just remember to change the result variables used in the checkResultsCB js function - they use the query's column names:
in my example the query returned columns id and name, and the js function used r.DATA.id and r.DATA.name.
you will need to change that to use columns returned by your query.
also remember that column names are case-sensitive in a way - they should be referenced in checkResultsCB function in same case as they are in the query sql in the cfc function.

Azadi

 

by: andrewaielloPosted on 2009-11-04 at 14:57:42ID: 25744984

Thanks again!  I am very close to getting it working.  Everything is okay except the part where the notice for new results displays; I narrowed it down, keeping in mind what you said about case sensitivity; but I notice that the alert in the below code does not show up (wheras a similar alert in your original code does, or if i put like alert("Yo") instead)...something goes wrong here; its almost like the CFC function fails for some reason; i removed the query and tried it separately and it worked so I don't think its just a SQL error.

Thanks!

checkResultsCB = function(r) {
	// callback for checkResults function
	var ttlres = r.ROWCOUNT; //ROWCOUNT is part of json object returned by cfc function call
	if (ttlres > newResults) {
		var tr = ''; //this will hold html for new rows for the results table
		alert(r.DATA.RecordID[0]);
		for (var i=0; i<ttlres; i++) {
			if (r.DATA.RecordID[i] > curMaxID) tr += '<tr class="newresult"><td width="20">'+r.DATA.RecordID[i]+'</td><td>'+r.DATA.message[i]+'</td></tr>';
		} //only create rows for results which do not already have rows created for them
		curMaxID = r.DATA.RecordID[0]; //reset curMaxID to max id value returned by current cfc call. our query returns data ordered desc by id, so the first id in the result is the max id
		newResults = ttlres; //reset newResults var to ttlres
		$('#resultstable tbody').prepend(tr); //add new result rows to top of results table
		$('#newresults').find('#numres').html(newResults).end().fadeIn(); //show new results notification
		$('#numrowsadded').html('');
	}
}; 

//relevant function in cfc 
	<cfargument name="maxID" type="numeric" required="no" default="0">
		<cfset var q = "">
		<cfquery name="q" datasource="#application.datasourceName#">
		SELECT
        	RecordID, message
		FROM 
        	DwitterStatusUpdates
		WHERE RecordID > <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.maxID#">
		ORDER BY RecordID DESC
		</cfquery>
		<cfreturn q />
	</cffunction>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:

Select allOpen in new window

 

by: azadisaryevPosted on 2009-11-04 at 23:32:37ID: 25747393

hmm.. nothing wrong jumps out at me in that code...

you say when you change alert(r.DATA.RecordID[0]); in the above code to alert('Yo!'); you do see the alert then?
if so, there's probably something wrong with the data returned by cfc call and we need to do some debugging...
the best tool for this is Firefox+Firebug add-on - if you are not already using them you should start now.

for starters, add console.log(r); as the first line in the checkResultsCB function, reload the page with Firebug open, copy the output from Firebug's console tab and post it here.

Azadi

 

by: andrewaielloPosted on 2009-11-05 at 08:05:58ID: 25750898

Yes, if i changed that alert to 'Yo' it would indeed appear.  

Okay while using firebug; the output, before I add any new rows; is as follows:

//10 seconds after page load with no new records added:
Object ROWCOUNT=0 COLUMNS=[2] DATA=Object 

//after one press of the add new button
Object ROWCOUNT=3 COLUMNS=[2] DATA=Object
r.DATA.RecordID is undefined
anonymous(Object ROWCOUNT=3 COLUMNS=[2] DATA=Object)DwitterNew (line 66)
anonymous()cfajax.js (line 487)
anonymous()cfajax.js (line 473)
anonymous()cfajax.js (line 172)
anonymous()cfajax.js (line 125)
[Break on this error] alert(r.DATA.RecordID[0]);\r\n 
//after second press of add new button (similar for subsequent presses
Object ROWCOUNT=8 COLUMNS=[2] DATA=Object

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:

Select allOpen in new window

 

by: andrewaielloPosted on 2009-11-05 at 08:11:50ID: 25750951

Here is some more info from that output after I press the add new button (new to firebug):

//in the "Response" tab 
{"ROWCOUNT":5,"COLUMNS":["RECORDID","MESSAGE"],"DATA":{"RECORDID":[47,46,45,44,43],"MESSAGE":["New Message","New Message","New Message","New Message","New Message"]}}

                                              
1:
2:
3:

Select allOpen in new window

 

by: azadisaryevPosted on 2009-11-05 at 08:22:12ID: 25751052

need to see what's in the DATA object.

in firebug console tab you should see lines like GET http://... appear every 10 seconds.
click on one of those to expand it, then click on Response tab and copy the response text and post here.

(if you can't see the http requests listed in the console tab - click on the little arrow on the tab title and select "Show XMLHTTPRequests" option)

you should also be able to click on the {ROWCOUNT=... lines to see the full object in the DOM tab. next to DATA object there look at the names of properties returned - is there one called RecordID ? is it in the same case as you are using or different?

Azadi

 

by: andrewaielloPosted on 2009-11-05 at 08:27:00ID: 25751096

I think I have pasted that in the post right above your current one (I double posted so maybe you only saw the first one).  I see the RecordID there; but (like the message one too) is in all caps; nowhere do I have write it in all caps in the code.  Do you need something else besides what is above?

 

by: azadisaryevPosted on 2009-11-05 at 08:27:02ID: 25751097

ha, you beat me to it!

>> "DATA":{"RECORDID":[47,46,45,44,43],"MESSAGE":["New Message","New Message","New Message","New Message","New Message"]}}

as you can see, the column names are returned in UPPERCASE.
you need to use RECORDID and MESSAGE (all uppercase) instead of RecordId and message in the js code.

i think the difference is that my data was returned from a QoQ, while yours is returned from a real db query - thus mine was being returned in the case as i had the column names in the QoQ's SQL, but yours is converted to all uppercase.

Azadi

 

by: andrewaielloPosted on 2009-11-05 at 08:30:20ID: 25751136

Yeah I gotcha; I guess what was throwing me is that I reference lower case "message" in my code and it didn't give a problem like this; i case the case sensitivity only matters sometimes depending on what you are doing with it?  In the meantime I will change that to all caps and see what happens!

 

by: azadisaryevPosted on 2009-11-05 at 08:30:55ID: 25751144

just to be clear:

change your
alert(r.DATA.RecordId[0]);

to:
alert(r.DATA.RECORDID[0]);

and also change
if (r.DATA.RecordID[i] > curMaxID) tr += '<tr class="newresult"><td width="20">'+r.DATA.RecordID[i]+'</td><td>'+r.DATA.message[i]+'</td></tr>';

to:
if (r.DATA.RECORDID[i] > curMaxID) tr += '<tr class="newresult"><td width="20">'+r.DATA.RECORDID[i]+'</td><td>'+r.DATA.MESSAGE[i]+'</td></tr>';

as well as curMaxID = r.DATA.RecordID[0]; to curMaxID = r.DATA.RECORDID[0];

Azadi

 

by: andrewaielloPosted on 2009-11-05 at 08:33:38ID: 25751167

Yeah that worked!  The strange thing I am noting here is that r.Data.message works as lower case OR upper case... why did it not matter for message and it did for recordID?

 

by: azadisaryevPosted on 2009-11-05 at 08:37:01ID: 25751213

cf returns structures create with dot notation (i.e. somestructure.somekey) to all uppercase. same goes for returning queries which are a special case of structures.

structures created using array notation (somestructure['somekey']) will be returned in the case the key was defined.

this is not an issue when your returned data is consumed by cf code, which does not care about the case, but it makes all the difference when returned data is consumed by javascript which is case-sensitive.

i didn;t know that QoQ were treated differently by cf (or maybe it's not QoQs but queries created using querynew() function... will need to test it out) and that threw me off a bit, even though i knew that cf returns most things in uppercase.

Azadi

 

by: azadisaryevPosted on 2009-11-05 at 08:39:49ID: 25751251

>> why did it not matter for message and it did for recordID?

my guess would be because message was in all lower-case, while RecordID was in mixed-case... but i will need to run some tests to say for sure, and to see how exatly the case matters (i.e. what would have happened if you had it named as recordID...)

Azadi

 

by: andrewaielloPosted on 2009-11-05 at 08:41:41ID: 25751271

Hmm okay; well at least it was interesting!  

I have some follow up questions on this project here; simple ones (I think) that I may somewhat know the answer to already.  Should I post them here; or should I close this out and start a new question.  You've been very helpful and I want to make sure you get the proper points ;)

 

by: andrewaielloPosted on 2009-11-05 at 08:42:33ID: 25751282

You could also post a quick summary on the other thread and I'll close that one out as well.

 

by: azadisaryevPosted on 2009-11-05 at 08:46:03ID: 25751327

keep posting them here - it will be easier to follow the code and conversation in one place than having to jump from one question to another.  it will probably also be better for someone looking for this solution later...

i also think you can close the first question you had opened on this subject (the one i had neglected for too long) and request full points refund for that one. explain that you opened a new question on exactly same subject and link to this question in the reason to close the first one.

so, what's the next question? :)

Azadi

 

by: andrewaielloPosted on 2009-11-05 at 08:55:04ID: 25751453

K sounds good, thanks! ;)

Okay; as we are now well aware the records currently consist of RecordID and Message; this was a simplification of what I am working on. There will actually be another field "category" that could be one of a few things (lets say 3).  So for instance, this table might have records that look like

1, myMessage, category1
2, myMessage, category2
3, myMessage, category3
4, myMessage, category2

and so on.  So basically the page is going to have a a few separate sections (corresponding to the categories), and I want this kind of update noticing of new records happening in each section, but only for message with the category of that section.  I hope that makes sense.  Now; I think I understand what I have to do; basically make 3 separate database searches instead of one (one for each category) and handle it all similarly.  I just want to make sure this is the most efficient way; as if say there are 20 questions; would it be a problem to make these 20 search calls every 10 seconds?  Or is there some kind of magic SQL way to make one DB call and then parse it into 20 different result sets (that then are what is used to do the update noticing) etc.  

That was a little convoluted but I hope it made sense!

 

by: andrewaielloPosted on 2009-11-05 at 08:56:17ID: 25751472

I said 20 "questions" up there by mistake: i meant 20 categories lol

 

by: azadisaryevPosted on 2009-11-05 at 09:11:03ID: 25751633

my first thought would be that, yes, you need to make 20 separate calls to the cfc - one for each category...

but then... all you really need is a separate new results counter for each section, and you can return all data in one query in one call. of course, you won't be able to use the very handy ROWCOUNT variable - you will have to create a custom counter for each category in js.

let me adjust my sample code to include multiple categories - you can then have a look at the code to see how to do it.

Azadi

 

by: andrewaielloPosted on 2009-11-05 at 09:16:28ID: 25751672

Okay; thanks.  I'm thinking that I might get stuck having to make seperate DB calls for each category in case I want to do more specific things.  Like for instance lets say on page start up I'd want to start out displaying the 10 most recent message for each category; I might have to do that doing each separate call and ordering them be RecordID (or timestame) DESC and limiting to 10...but then again maybe that can be done with SQL Parsing magic too.  

 

by: andrewaielloPosted on 2009-11-05 at 09:18:19ID: 25751688

Also; in truth the number of categories will be variable; so my plan is to, on page start up, pool the DB to get the categories; and then in all this subsequent stuff just looping over the categories and doing all this other stuff.

 

by: andrewaielloPosted on 2009-11-05 at 09:20:33ID: 25751715

Actually; maybe not just on page start up for checking the categories; but at every interval (in case for some reason a category gets added or dropped while the page is sitting there.  Sorry for my rapid fire posts; just want to get any information up here before you dive in; don't want to lead you in circles.

 

by: andrewaielloPosted on 2009-11-09 at 07:35:22ID: 25776773

Lol, looks like I lost you again.

 

by: azadisaryevPosted on 2009-11-14 at 02:13:06ID: 25820058

i am with you!
had some urgent work (again), but i am testing an application that uses multiple categories right now. will post code later today or tomorrow.

Azadi

 

by: andrewaielloPosted on 2009-11-14 at 11:35:55ID: 25822002

Your alive!  Thanks for getting back; I'm always busy too so I understand ;)  

I started doing something myself too, but I'm sure you can come up with a more streamlined way of doing it then I am doing; thanks again!

 

by: andrewaielloPosted on 2009-11-14 at 11:40:53ID: 25822023

I basically just was doing a query to get the distinct people in the room; and then looped through them all doing sql queries for each person, to see if they have new records and changing their section accordingly.  Again this may be clunky compared to the way are doing.

 

by: andrewaielloPosted on 2009-11-14 at 11:44:27ID: 25822035

Oops; i meant to say categories instead of people; hopefully you knew what I was saying (the categories obviously correspond to company members lol).

 

by: azadisaryevPosted on 2009-11-16 at 00:46:07ID: 25828644

well, here it is!
categories support and all - with just one query and one ajax call.

the code (js mostly) is significantly more complex than in the previous version, all because of multiple categories of results.

the code is commented as much as i could.

2 important issues:
1) your data must be returned by 1 query. it is almost always possible to do this, but to say for sure i will need to see your db structure.
2) IDs of html elements in the code are very important - especially the ones that include the Category identifier (#CAT#, which in my example it is a numeric value, but it could be a sting es well, though some js may have to edited to account for this). js code uses these IDs extensively and won;t work without them.

have a look/play with the code, and shout if you have any questions.

Azadi

  • -rtresults2.zip
    • 4 KB

    unzip + remove .txt extension from files; run index.cfm

 

by: andrewaielloPosted on 2009-11-16 at 13:39:32ID: 25834430

Wow, really impressive!  Definitely more streamlined then what I was doing, lol.  I am working on integrating into my project now; so far so good; I'll write back with a status update soon.

 

by: andrewaielloPosted on 2009-11-23 at 08:23:20ID: 25888968

Still here; just got tied up with other work.  So far so good; I'm just trying to modify it to make new rows in a single table for each new category as opposed to separate tables.

 

by: azadisaryevPosted on 2009-11-23 at 08:25:55ID: 25888988

post your tables structure if you get stuck creating a single query.

Azadi

 

by: andrewaielloPosted on 2009-11-23 at 13:41:43ID: 25891866

I got everything working with my DB data perfectly; just wrestling with formatting changes ugh ;)  Now my boss wants it so there is just one table, with a row in it for each category, and only 1 record (the newest one) showing at a time with a link to display older records which will make some older records appear below that in "subrows"  

Oiy!  

I'm trying to figure out how to adapt based on your extremely well commented code; but your java kung fu is far superior to mine so its been slow going.  I'm currently focusing on this:

var tr = '<tr class="newresult"><td width="20">'+r.DATA.ID[i]+'</td><td>'+r.DATA.NAME[i]+'</td></tr>'; // create html for new result row...

as that is clearly related.  

 

by: azadisaryevPosted on 2010-01-11 at 03:23:41ID: 26282161

@andrewaiello:

your new requirement is rather different from your original question...
i will be happy to help you with it if it is still relevant and if you open a new question for it.

@angelIII:

i believe i have provided a solution to the original question, which has been acknowledged by the OP in his last comment. in case the OP does not finalize the question in time and you need to close it, i will appreciate if you kept that in mind.

Azadi

 

by: andrewaielloPosted on 2010-01-18 at 14:46:46ID: 26345261

@angelll

Sorry I forgot about this for a while; I have closed the quesiton with aza's answer.  

@aza

I apologize for being away for a while!  Yes, I am still struggling with this other aspect; how best do you think I should phrase this as a new quesiton (since it obviously relies a lot on the info here).  Thanks!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...