[英]How to run a php file from flex (mxml/actionscript?
How do I execute php code which is in another file from my flex application? 如何执行Flex应用程序中另一个文件中的php代码?
The php code I want to execute (nice and simple) 我要执行的php代码(简洁明了)
<?php
echo "My first PHP script!";
?>
So I want the above to execute. 所以我希望以上执行。 So far I have this in my flex application:
到目前为止,我的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"/>
So I'm running it locally at the moment. 因此,我目前正在本地运行它。 I think there needs to be something on "click-"userRequest.(somethinghere)"/> but not sure what it needs to be.
我认为“ click-” userRequest。(somethinghere)“ />上需要包含一些内容,但不确定是否需要。
I use the UrlLoader class 我使用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);
Try first your php n your browser see if you can get the correct url, it should be something with localhost or 127.0.0.1 like 首先尝试在浏览器中查看php,看看是否可以获得正确的url,它应该是localhost或127.0.0.1之类的东西
http://localhost/myscript.php
Edit as Josh suggested in the comments you MUST have a web server with PHP support installed and setup. 按照评论中的Josh的建议进行编辑,您必须拥有安装和设置了PHP支持的Web服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.