我正在使用URLLoader将一些键/值对发送到php脚本,然后将其转换为电子邮件,发送(或不发送),然后使用响应回显字符串.
起初它工作正常.URLLoader发布,一分钟后我收到了我的电子邮件,但由于某种原因,我没有得到我的回复.事实上,我的COMPLETE事件似乎根本没有发生.这让我感到困惑,因为如果我收到我的电子邮件,我知道我必须正确发送所有内容.这是我的代码:
public class Mailman{ public static const METHOD:String = URLRequestMethod.POST; public static const ACTION:String = "mailer.php"; public static var myLoader:URLLoader = new URLLoader(); private static function onMessageProgress(e:Event){ var L:URLLoader = e.target as URLLoader; Output.trace("PROGRESS: "+L.bytesLoaded+"/"+L.bytesTotal); for(var k in L){ Output.trace(" "+k+": "+L[k]); } } private static function onOpen(e:Event){ Output.trace("Connection opened"); } private static function onComplete(e:Event){ Output.trace("Complete!"); } private static function onStatusChange(e:HTTPStatusEvent){ Output.trace("Status Changed to "+e.status); } private static function onMessageFail(e:Event){ PanelManager.alert("ERROR: Could not send your request. Please try again later."); } public static function sendMessage(recipient:String,subject:String,message:String){ var _vars:URLVariables = new URLVariables(); _vars.recipient = recipient; _vars.subject = subject; _vars.message = message; var req:URLRequest = new URLRequest(ACTION); req.data = _vars; req.method = METHOD; myLoader.dataFormat = URLLoaderDataFormat.VARIABLES; myLoader.addEventListener(ProgressEvent.PROGRESS,onMessageProgress); myLoader.addEventListener(Event.OPEN,onOpen); myLoader.addEventListener(Event.COMPLETE,onComplete); myLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS,onStatusChange); myLoader.addEventListener(IOErrorEvent.IO_ERROR,onMessageFail); myLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onMessageFail); myLoader.load(req); } public static function test(){ sendMessage("john@example.com","test","this is a test message."); } function Mailman(){} }
当我打电话时Mailman.test()
,我收到的电子邮件完全像我期望的那样,这就是追踪:
Connection opened PROGRESS: 45/45 Status Changed to 0
怎么会这样?如果我正确理解文档,Open事件发生在我开始下载我的响应时,并且显然正在发生,那么如何才能获得http状态为0?有任何想法吗?