Returning JSON to CF/jQuery
CF page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(e) {
$.getJSON('loaddata.cfm',function(data){
$("#div1").html(data);
});
});
</script>
</head>
<body>
<div id="div1" style="background-color:tan; height:70px; width:450px;"></div>
</body>
</html>
loaddata.cfm
<cfquery datasource="pubs" name="jquerytest">
Select * from jquery
</cfquery>
<cfoutput>#serializejson(jquerytest)#</cfoutput>
loaddata.cfm is displaying {"COLUMNS":["ID","TITLE","CONTENT"],"DATA":[[1,"Dave","test content 1"],[2,"Bob","test content 2"],[3,"Jesse","test content 3"]]}
I'm having an issue returning this CF query in JSON format. It's available but I'm not sure what format/structure jQuery expects, what I have isn't outputting any data. My
$("#div1").html(data);isn't displaying any data.