Flex:将信息发送到 Coldfusion 文件后从 URLLoader 获取反馈

发布于 2024-11-17 16:00:03 字数 1809 浏览 0 评论 0原文

我有一个日程安排应用程序,允许用户保存任何更改。当用户单击“保存”按钮时,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

且行且努力 2024-11-24 16:00:03
progressOutLoader.addEventListener(Event.COMPLETE,resultHandler);

public function resultHandler(event:Event):void {
 Alert.show("Success");
}

同样处理其他事件。
http://help.adobe.com/en_US /FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html

为什么不使用 Flex HTTPService?而不是 URLLoader

progressOutLoader.addEventListener(Event.COMPLETE,resultHandler);

public function resultHandler(event:Event):void {
 Alert.show("Success");
}

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文