我正在使用 Coldfusion 9 和 Sql Server 2008 r2。我正在尝试使用显示结果的实时搜索。
我想为此添加一个表格,以便对其进行格式化。任何帮助都会很棒。
这是 Search.cfm
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(document).ready(function() {
//http://stackoverflow.com/questions/217957/how-to-print-debug-messages-in-the-google-chrome-javascript-console/2757552#2757552
if (!window.console) console = {};
console.log = console.log || function(){};
console.dir = console.dir || function(){};
//listen for keyup on the field
$("#searchField").keyup(function() {
//get and trim the value
var field = $(this).val();
field = $.trim(field)
//if blank, nuke results and leave early
if(field == "") {
$("#results").html("");
return;
}
console.log("searching for "+field);
$.getJSON("test.cfc?returnformat=json&method=search", {"search":field}, function(res,code) {
var s = "";
s += "<h2>Results</h2>";
for(var i=0; i<res.fd_table.length; i++) {
s += "<p><b>uid:"+res.fd_table[i].fd_uid+"</b><br/>Device: "+res.fd_table[i].fd_dev + "<br/>";
}
$("#results").html(s);
});
});
})
<form>
Search: <input type="text" name="search" id="searchField">
</form>
<div id="results"></div>
演示来自原始帖子http://www.coldfusionjedi.com/demos/feb12011/test.cfm
这是我试图达到的最终结果。