[jQuery] A newbie with an ajax-via-jquery question
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1">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.
</font><font size="-1">Here's my client side code:
</font>
<font size="-1"><tt><CFSet
ClientNumberList="172104|188549|111304|169080|028267|203347">
<CFOutput>
<html>
<head>
<script type="text/javascript"
src="/include/js/jquery.js"></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>
</tt></font><font size="-1">Here's my server side code:
</font><font size="-1"><tt><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></tt></font><font size="-1">
</font><font size="-1">
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.
</font>
<font size="-1">Any thought on just what the heck I'm doing wrong? :)
</font>
<font size="-1">Thanks,
Chris
</font>
</body>
</html>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/