2011-02-23 24 views
0

問題:問題與運行PHP文件,Flex項目的發佈

我打電話使用的HTTPService的PHP文件。我將這個HTTPService的結果設置爲一個函數,該函數用PHP文件返回(回顯)填充testTextArea。這個工作很好,當我從Flash builder運行應用程序時,即我得到了testTextArea中的字符串,並由我的PHP文件迴應。但是,當我使項目的發佈和testTextArea被PHP文件的整個代碼填充時,這不起作用。

代碼:

 private function addUserServiceHandler(event:ResultEvent):void{ 
      testTextArea.text = event.result.toString(); //This outputs the whole php file in to the textArea as if it were a string 
     } 


     private function saveButtonClicked():void{ 
      addUserService.send(); 
     } 

    ]]> 
</fx:Script> 

<fx:Declarations> 
    <mx:HTTPService id="addUserService" url="addUser.php" resultFormat="text" method="POST" result="addUserServiceHandler(event)" > 
     <mx:request xmlns=""> 
      <firstName>{firstNameTextInput.text}</firstName> 
      <lastName>{lastNameTextInput.text}</lastName> 
      <imageName>{uploadTextInput.text}</imageName> 
      <adultContent>{adultContentRadioGroup.selectedValue}</adultContent> 
      <p2p>{p2pRadioGroup.selectedValue}</p2p> 
      <priority>{priorityRadioGroup.selectedValue}</priority> 
     </mx:request> 
    </mx:HTTPService> 
<fx:Declarations> 



<s:Button id="saveButton" includeIn="AddUser" x="313" y="128" label="Save" width="187" height="33" click="saveButtonClicked()"/> 
+0

這可能只是一個'crossdomain.xml'問題? – Jakub 2011-02-23 15:31:22

+0

不知道...當我用Flex 3工作時,從來沒有遇到過這個問題 – baltoro 2011-02-23 15:44:52

+0

那麼你有沒有一個crossdomain.xml文件可以訪問該PHP文件?我假設它可能被阻止..爲什麼不嘗試在飛行中調試?我不能告訴你什麼是錯的,我給你的建議,你需要有'想法' – Jakub 2011-02-23 15:48:05

回答

0

問題出現了,因爲我通過雙擊錯誤地從硬盤運行我的html文件,即我沒有在本地主機上運行它。

0

被配置服務的PHP文件中的生產服務器?這聽起來像你的Web服務器正在以文本文件的形式提供PHP文件。

將生產服務器上的文件info.php的(在同一目錄addUser.php)具有以下內容:

<?php 
phpinfo(); 
?> 

,然後直接導航到它在瀏覽器中。如果你看到上面的文字,那麼你需要讓PHP工作。

+0

謝謝jdusbabek。我錯誤地沒有用http:// localhost運行html文件。這就是問題出現的原因。 – baltoro 2011-02-24 06:01:01