我正在尝试开发一个phonegap应用程序,它将调用我的coldfusion服务器并将数据返回到手机应用程序.我看过几个没有解释服务器端代码的教程(.cfc文件).喜欢这个... http://blog.ryanvikander.com/index.cfm/2012/3/28/Returning-Dynamic-Content-In-A-PhoneGap-App
我希望有人可以提供一些示例代码,说明我的服务器上收到数据请求时的.cfc.
我很喜欢Coldfusion,并通过网址通过网络传递表格中的变量.我无法绕过这个移动设备.我正在开发一个从我的服务器上的数据库中提取的应用程序.我现在有2次调用服务器只是在没有任何"where"语句的情况下提取数据,而且它们工作得很好.我想添加一个搜索输入,该输入将包含用户在框中输入的内容,以便在我的.cfc中查询.不确定如何将电话表格中的数据传递到我服务器上的cfc.
这是搜索按钮代码......
<form action="searchresult.html" method="post" data-transition="none">
<input type="search" name="mySearch"
id="mySearch" value="" data-mini="true" data-theme="b" />
</form>
Run Code Online (Sandbox Code Playgroud)
这是我在XCode中的脚本代码,应该在提交搜索时运行...(我不知道将任何变量传递到cfc的位置.可以在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"
);
});
Run Code Online (Sandbox Code Playgroud)
这是我在服务器上的cfc ......
component {
remote array function getsearch() …Run Code Online (Sandbox Code Playgroud) 我正在使用pushwoosh.com服务为phonegap实现推送通知插件.我按照这个教程... http://www.pushwoosh.com/programming-push-notification/push-notification-sdk-integration-for-phonegap/
在我的配置文件出现问题并遇到错误后,我现在在运行应用程序时出现"警告"错误.这是错误的屏幕截图...
当我谷歌时,我没有看到任何关于该错误的信息.我已经多次查看了我的代码,并没有看到任何突出的"错误".我希望这里的其他人有这个问题并以某种方式解决了它.
我的服务器上有一个.cfc,用于运行查询并将结果发送回phonegap应用程序.我无法正确检查语法是否在查询中返回任何数据并在结果中发回一个字符串,如"找不到数据"来显示.这是我的代码......
remote array function getintList() {
var q = new com.adobe.coldfusion.query();
q.setDatasource("myData");
q.setSQL("select id1, Date, ShowLInk, IntName, description from myData Where intyear = #dateformat(Now(), "YYYY")# 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;
}
Run Code Online (Sandbox Code Playgroud)
想也许我可以做这样的cfif语句,但它不起作用......
<cfif data.recordcount lt 1>
result = "no data"
return result;
<cfelse>
return result;
</cfif>
Run Code Online (Sandbox Code Playgroud)
希望可以有人帮帮我.