我非常喜欢Coldfusion,并通过URL通过Web在表单中传递变量。我无法把头围绕在这个移动的东西上。我正在开发一个从我的服务器上的数据库中提取的应用程序。我现在有2个调用服务器的服务器,它只是在没有任何“where”语句的情况下提取数据,并且它们工作得很好。我想添加一个搜索输入,该输入将在用户在我的.cfc查询框中输入用户键入的内容。不知道如何将数据从手机表单传递到服务器上的cfc。Coldfusion CFC的JQuery搜索输入
下面是搜索按钮的代码...
<form action="searchresult.html" method="post" data-transition="none">
<input type="search" name="mySearch"
id="mySearch" value="" data-mini="true" data-theme="b" />
</form>
这是在我的XCode脚本代码应该运行在搜索提交...(我不知道往哪里放任何变量传递商品共同基金。它可以在URL中传递?)
$("#resultPage").live("pageshow", function() {
console.log("Getting remote list" + event.notification);
$.mobile.showPageLoadingMsg();
$.get("http://www.mywebsite.com/jquery/ryprad.cfc?
method=getsearch&returnformat=json",
{},
function(res) {
$.mobile.hidePageLoadingMsg();
var s = "";
for(var i=0; i<res.length; i++) {
s+= "<li><a name=" + res[i].id + " + href='"
+ res[i].showlink + "'>"
+ res[i].date + "<br/>" + res[i].name + "<br/>"
+ res[i].description + "</a></li>";
}
$("#resultList").html(s);
$("#resultList").listview("refresh");
},
"json"
);
});
这是我的服务器上的CFC ...
component {
remote array function getsearch() {
var q = new com.adobe.coldfusion.query();
q.setDatasource("myDat");
q.setSQL("
select id1, Date, ShowLInk, IntName, description from RYPRadio
Where intName
LIKE '%#VARIABLE_FROM_PHONE_SEARCH#%'
order by date desc"
);
var data = q.execute().getResult();
var result = [];
for(var i=1; i<= data.recordCount; i++) {
arrayAppend(
result,
{
"id"=data.id1[i],
"name"=data.IntName[i],
"date"=dateformat(data.date[i], "mmmm d, yyyy"),
"description"=data.description[i],
"showlink"=data.ShowLInk[i]
}
);
}
return result;
}
}
我希望有人能为此提供帮助。如果我能得到这个工作,它将帮助我开发其他能够传递变量的东西!
这是否类似于您要执行的Google Suggest过滤器/搜索?是的,您可以通过URL将数据传递给CFC。 – BKK 2012-07-05 21:19:26