如何从flex(mxml/actionscript)运行php文件?
如何执行flex应用程序中另一个文件中的php代码 我想要执行的php代码(很好,很简单)如何从flex(mxml/actionscript)运行php文件?,php,apache-flex,actionscript,mxml,Php,Apache Flex,Actionscript,Mxml,如何执行flex应用程序中另一个文件中的php代码 我想要执行的php代码(很好,很简单) 因此,我希望执行上述操作。到目前为止,我的flex应用程序中有: <mx:HTTPService id="userRequest" url="C:\Users\blah\blah\blah\src\ItemTableService.php" useProxy="false" method="POST"> </mx:HTTPService> </fx:Decla
因此,我希望执行上述操作。到目前为止,我的flex应用程序中有:
<mx:HTTPService id="userRequest" url="C:\Users\blah\blah\blah\src\ItemTableService.php" useProxy="false" method="POST">
</mx:HTTPService>
</fx:Declarations>
<mx:Button label="Submit" click="userRequest"/>
所以我现在正在本地运行它。我认为“click-”userRequest.(somethinghere)/>上需要一些东西,但不确定它需要什么。我使用UrlLoader类
var url:String="example";
var urlRequest:URLRequest=new URLRequest(url);
urlRequest.method=URLRequestMethod.POST;
//use variables only if yu need them
var variables : URLVariables = new URLVariables();
variables.something=ex;
urlRequest.data=variables;
var urlLoader:URLLoader=new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, onComplete);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR,onError);
urlLoader.load(urlRequest);
首先在你的浏览器上试试你的php,看看你是否能得到正确的url,它应该是localhost或者类似127.0.0.1的东西
http://localhost/myscript.php
按照Josh在评论中的建议进行编辑,您必须安装并安装一台支持PHP的web服务器。值得注意的是,PHP也需要运行服务器软件。仅在您的系统上安装文件是不够的,您需要运行Apache或类似软件(通常通过XAAMP/WAMP/MAMP或类似软件)才能运行它。
http://localhost/myscript.php