![](/img/trans.png)
[英]How to make returned from PHP Data fill MXML Flex mx:List (Using actionscript and PHP)
[英]How to run a php file from flex (mxml/actionscript?
如何執行Flex應用程序中另一個文件中的php代碼?
我要執行的php代碼(簡潔明了)
<?php
echo "My first PHP script!";
?>
所以我希望以上執行。 到目前為止,我的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服務器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.