Flex:将信息发送到 Coldfusion 文件后从 URLLoader 获取反馈
我有一个日程安排应用程序,允许用户保存任何更改。当用户单击“保存”按钮时,Flex 会将所有信息发送到 Coldfusion 脚本,该脚本将信息分开并将其保存到数据库中。这一切都运行良好,但我希望能够向用户显示某种文本,例如“您的文件已成功保存”或“出现错误。请联系管理员”。
我的AS功能如下:
import flash.net.URLLoader;
import flash.net.URLRequest;
private function save():void
{
var tempString:String = new String;
// Set up a URL request, loader, and variables
var progressOutURL:URLRequest = new URLRequest("saveSchedule.cfm");
var progressOutLoader:URLLoader = new URLLoader();
var progressOutVars:URLVariables = new URLVariables(); // Set the variables to be sent out
for (var i:int = 0; i < wholeProject.length; i++)
{
tempString = new String;
tempString = wholeProject[i].projectTitle + "|" + wholeProject[i].workingTitle + "|" + wholeProject[i].startDate + "|";
for (var j:int = 0; j < wholeProject[i].thisBlock.length; j++)
{
tempString = tempString + wholeProject[i].thisBlock[j].startOffset + "," + wholeProject[i].thisBlock[j].numDays + "," + wholeProject[i].thisBlock[j].role + "," + wholeProject[i].thisBlock[j].sID + "," + wholeProject[i].thisBlock[j].isConflict + "," + wholeProject[i].thisBlock[j].positionType + ";";
}
progressOutVars["project" + i] = tempString;
}
progressOutURL.method = URLRequestMethod.POST;
progressOutURL.data = progressOutVars;
progressOutLoader.load (progressOutURL);
}
我的coldfusion文件如下(现在它只是保存信息的cfdump,以便我可以确定数据已发送):
<cfsavecontent variable="toOutput">
<cfdump var="#FORM#" />
</cfsavecontent>
<cffile action="write" file="#GetDirectoryFromPath(GetCurrentTemplatePath())#output.html" output="#toOutput#" />
有什么办法可以让“progressOutLoader.load(progressOutURL) ;”返回一个布尔值或其他内容说明发送是否成功?
I have a scheduling application that allows users to save any changes. When the user clicks the save button, Flex sends all the information to a coldfusion script which picks the information apart and sends saves it to the database. That all works well and good, but I would like to be able to display some sort of text to the user saying something like "Your file was successfully saved" or "There has been an error. Please contact the administrator".
My AS function is as follows:
import flash.net.URLLoader;
import flash.net.URLRequest;
private function save():void
{
var tempString:String = new String;
// Set up a URL request, loader, and variables
var progressOutURL:URLRequest = new URLRequest("saveSchedule.cfm");
var progressOutLoader:URLLoader = new URLLoader();
var progressOutVars:URLVariables = new URLVariables(); // Set the variables to be sent out
for (var i:int = 0; i < wholeProject.length; i++)
{
tempString = new String;
tempString = wholeProject[i].projectTitle + "|" + wholeProject[i].workingTitle + "|" + wholeProject[i].startDate + "|";
for (var j:int = 0; j < wholeProject[i].thisBlock.length; j++)
{
tempString = tempString + wholeProject[i].thisBlock[j].startOffset + "," + wholeProject[i].thisBlock[j].numDays + "," + wholeProject[i].thisBlock[j].role + "," + wholeProject[i].thisBlock[j].sID + "," + wholeProject[i].thisBlock[j].isConflict + "," + wholeProject[i].thisBlock[j].positionType + ";";
}
progressOutVars["project" + i] = tempString;
}
progressOutURL.method = URLRequestMethod.POST;
progressOutURL.data = progressOutVars;
progressOutLoader.load (progressOutURL);
}
And my coldfusion file is as follows (right now it just saves a cfdump of the information so that I can be sure the data was sent):
<cfsavecontent variable="toOutput">
<cfdump var="#FORM#" />
</cfsavecontent>
<cffile action="write" file="#GetDirectoryFromPath(GetCurrentTemplatePath())#output.html" output="#toOutput#" />
Is there any way that the "progressOutLoader.load(progressOutURL);" returns a boolean or something saying whether or not the send was successful?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同样处理其他事件。
http://help.adobe.com/en_US /FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html
为什么不使用 Flex HTTPService?而不是 URLLoader
Similarly handle other events too.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html
Why are you not using Flex HTTPService? instead of URLLoader