Hi folks,

Rey Bango turned me on to jQuery, and I'm trying to use it right now pretty much for the first time. I'm trying to make an ajax call to my ColdFusion server. The upshot is that I'd like the server to build a row of a table and return the row to the client. Then I was hoping that I could use this .append() method to tack it on to the body of the table that already exists on the client side. Rey gave me a bit of sample code on a different list where he does something similar and I've adapted that to what shows below.

Here's my client side code:

<CFSet ClientNumberList="172104|188549|111304|169080|028267|203347">
<CFOutput>
<html>
    <head>
        <script type="text/_javascript_" src=""></script>
        <script type="text/_javascript_">
            $(document).ready(function(){
                var i,IDList;
                IDList = "#ClientNumberList#";
                IDList = IDList.split("|");
                for(i = 0; i < 1; i++){ // ignore the fact that I'm only looping one time here.
                    $.ajax({
                        type: "POST",
                        url: "MyJQueryTest.cfm",
                        data: "ClientID=" + IDList[i],
                        dataType: "html",
                        success: function(msg){
                            $("##searchResults" ).append(msg);
                        }
                    });   
                }
            });
          </script>
    </head>
    <body>
        <table width="100%" border="1" class="stripeMe" id="searchResults">
        <thead>
            <tr><th>My Sample Table</th></tr>
        </thead>
        <tbody>
            <tr><td>Row 1</td></tr>
        </tbody>
        </table>
    </body>
</html>
</CFOutput>

Here's my server side code:

<CFSet ThisClientNumber = Trim(FORM.ClientID)>
<CFQuery Name="GetSomeStuff" DataSource="AS400JDBC">
    SELECT    Cuscl,Spkpa,Custc
    FROM    NFCustTest.NRMRK001
    WHERE    CUSTC = '#ThisClientNumber#'
</CFQuery>

<cfcontent type="text/html" reset="Yes" />
    <cfheader name="Content-Type" value="text/html; charset=UTF-8">
    <cfsavecontent variable="searchResults">
    <CFoutput>
    <tr>
        <td>#Trim(GetSomeStuff.Custc)#</td>
        <td>#Trim(GetSomeStuff.Cuscl)#</td>
        <td>#Trim(GetSomeStuff.Spkpa)#</td>
    </tr>
    </CFoutput>
</cfsavecontent>


I'm having trouble getting this to work. The append doesn't seem to be doing what I want. If I append the output of the called cfm page to a div with an id, then I get sorta what I expected. I get the string that contained the constructed table row, but I also get all the CF Debugging information too. If I try to append to the table, then nothing happens.

Any thought on just what the heck I'm doing wrong? :)

Thanks,
Chris

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to