AS3 Passing and getting data to ASP

匿名 (未验证) 提交于 2019-12-03 02:13:02

问题:

I've been researching for days on the issude but till now I still haven found a solution yet. I have 0 knowledge on ASP. And I just want to able to pass and get var/text from ASP.

Anyone kind enuff to guide me how I can furthur from here?

private function loadASP():void {         var aspSend:URLRequest=new URLRequest("testASP.asp");         var aspLoader:URLLoader = new URLLoader();          aspLoader.load(aspSend);          trace("did send");         //aspLoader.addEventListener(Event.COMPLETE, processASP);     }      private function processASP(e:Event):void {     } 

回答1:

Why have you commented the call to addEventListener method? Uncomment it (and move it up two lines so that it comes before the load call). If the url is correct, the processASP method will be called when the response arrives (in a real life application, make sure you listen for ioError and securityError on the URLLoader - check the link for examples on doing this). You can read the response as e.target.data in the processASP method.

private function processASP(e:Event):void  {   var loader:URLLoader = URLLoader(e.target);   trace("Response is " + loader.data); } 

URLLoader can also be used to send data to the asp page (server).

var ldr:URLLoader = new URLLoader(); var data:URLVariables = new URLVariables(); data.something = "someData"; data.somethingElse = "moreData"; var request:URLRequest = new URLRequest("url.asp"); request.data = data; request.method = URLRequestMethod.POST;//or GET ldr.addEventListener(Event.COMPLETE, onLoad); //listen for other events ldr.load(request); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!