Nevermind.got it working.

 

I remembered some coding from a previous app that I built that did

the same thing.

 

Thanks for anyone looking over that looooong email!

 

Rick

 

From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Rick Faircloth
Sent: Wednesday, April 01, 2009 2:16 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] How can I get this title to display?

 

Hi, all.

 

I'm running a query (rather a couple of queries via ColdFusion) and then

returning the results via ajax for display on a page.

 

I'm using this code to output the results with no problem:

(shortened verson)

 

-------------------------------------------------------------------------

 

 

function populateTable(response) {

 

var out = [];

 

$.each(response.QGETSECTIONS.DATA, function(i, row) {

 

     out.push('<tr id = "' + row[0] + '">');

     out.push('<td>"' + row[1] + '"</td>');

     out.push('</tr>');

 

});

 

     $('#sectionsTable').html(out.join(''));

 

}

--------------------------------------------------------------------------

The code above displays the "sections" very well.

However, now I'd like to display a result from a different query, too,

which is title for the story to which the sections belong.

 

I tried writing a separate query and returning that data via ajax

along with the other data, which works fine, but I can't get the

data in this second query to display.  I tried this code:

 

---------------------------------------------------------------------------

 

function populateSectionsTable(response) {

 

     var out = [];

 

     $.each(response.QGETSTORY.DATA, function(i, row) {

 

          out.push('<tr>');

          out.push('<td>Contents of the story, "' + row [0] + '"</td>');

          out.push('</tr>');

 

     });

 

     $('#sectionsTable').html(out.join(''));

 

 

     var out = [];

 

     $.each(response.QGETSECTIONS.DATA, function(i, row) {

 

          out.push('<tr>');

          out.push('<td>"' + row[1] + '"</td>');

          out.push('</tr>');

 

     });

 

     $('#sectionsTable.html(out.join(''));

 

}

 

-------------------------------------------------------------------------

 

The code above runs without error, but nothing from the first

section of the query data  in response.QGETSTORY.DATA, etc., show up.

It's like there's nothing coming back in the ajax response.but it is,

I can see it in Firebug.

 

Here's the response I get in Firebug:

 

{     "QGETSECTIONS":

 

     {     "COLUMNS:" ["SECTION_ID", "SECTION_SUBTITLE", "TITLE"],

 

            "DATA":          [     [1, "First Section of CF Example", "My
First CF Example"],

                                             [2, "Second Section of CF
Example", "My First CF Example"],

                                             [3, "Third Section of CF
Example", "My First CF Example"],

                                             [4, "Fourth Section of CF
Example", "My First CF Example"]     ]

     },

 

     "MESSAGE":"Success",

 

     "QGETSTORY":

 

          {     "COLUMNS":  ["TITLE"],

 

                "DATA":     [      ["My First CF Example"]     ]

          }

}

 

----------------------------------------------------------------------------
-----

 

In the code, above, I get the title I'm trying to display, "My First CF
Example", in

the query, but can't figure out how to access it.via row[1,3] or whatever.

 

I tried running the separate query, "QGETSTORY" to reference it in the
output

of the table, but couldn't get that to work, either.

 

And, although I'm using ".each" in the second code example, I'm only
outputting

the title once.I just didn't know another syntax to use, to I thought I try
.each,

but just have it output the one result from the query.

 

Suggestions, anyone?

 

Thanks,

 

Rick

 

----------------------------------------------------------------------------
-----------------------------------------------------------

"It has been my experience that most bad government is the result of too
much government." - Thomas Jefferson

 

Reply via email to