doudi8231 2013-08-12 09:38
浏览 312
已采纳

flex 4:HTTP请求不发送值

Im making a small project in flex. The user can look up bookreviews. When types in the name of the book i get all the reviews back instead of the reviews of that particular book.

my code:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"

           >
<fx:Script>
    <![CDATA[
        import mx.rpc.events.ResultEvent;

        public function handleMenu(event:ResultEvent):void{
            DescrBooks.dataProvider = event.result.menu.menuitem;
        }
        public function Start():void{

            //favorieten.addEventListener(ResultEvent.RESULT,handleMenu);
            favorieten.send();
        }

        public function ShowBooks(SelectedBooks:Object):String{
            var descr:String = SelectedBooks.itemDesc;

            var D:String = descr

            return D;   

        }
    ]]>
</fx:Script>
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here     

    -->

    <s:HTTPService id="favorieten" 
                   url="http://www.gertjanvanhove2012.dreamhosters.com/script/ReviewsTest.php" method="POST"
                   result="handleMenu(event)"
                   >
        <s:request xmlns="" >
            <voorwerp>{TextTI.text}</voorwerp>
        </s:request>

    </s:HTTPService>
</fx:Declarations>


<mx:VBox x="14" y="60" width="744" height="450">
    <mx:Repeater id="DescrBooks" maxWidth="450">
        <mx:HBox>

            <mx:Text text="{ShowBooks(DescrBooks.currentItem)}" maxWidth="450" />

        </mx:HBox>  
    </mx:Repeater>
</mx:VBox>
<s:Button x="14" y="25" label="Button" click="Start()"/>
<s:TextInput x="92" y="25" id="TextTI"/>
</s:Application>

My php script:

<?php
header("Content-type: text/xml");
header("Expires: Mon, 26 Jul 1990 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// cache wordt uitgeschakeld om zeker te zijn dat de gegevens uit de API gelezen worden en niet uit de cache van de webbrowser
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
//alle gegevens om connectie te leggen naar de databank
    $host = "mysql.imd2012.dreamhosters.com";
    $user = "*********";
    $pass = "*********";
    $database = "gertjanvanhove2012";
//connectie leggen naar de databank
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
//gegevens gaan halen uit de databank
if(!isset($_GET['voorwerp'])){

$query = "SELECT * FROM RMA_Review ";

}
else{

$_GET['voorwerp'] = $tit;
$query = "SELECT * FROM RMA_Review where Title='".$tit."'";
}
$menu_result = mysql_query($query, $linkID) or die("Data not found.");
//starten met de opbouw van de string die de XML code bevat
$xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
";
$xml_output .= "<menu>
";
//voor elk menu item de nodige gegevens neerschrijven
for($x = 0 ; $x < mysql_num_rows($menu_result) ; $x++){
$itemrow = mysql_fetch_assoc($menu_result);
$xml_output .= "\t<menuitem>
";
$xml_output .= "\t\t<itemID>" . $itemrow['ReviewId'] . "</itemID>
";
$xml_output .= "\t\t<itemLabel>" . $itemrow['Title'] . "</itemLabel>
";
$xml_output .= "\t\t<itemDesc>" . $itemrow['Review'] . "</itemDesc>
";
$xml_output .= "\t\t<itemAutheur>" . $itemrow['Autheur'] . "</itemAutheur>
";
$xml_output .= "\t</menuitem>
";
}
$xml_output .= "</menu>
";
//de volledige XML string in de response echo'n
echo $xml_output;?>

the table RMA_Reviews looks like this: (cant post a screenshot because i dont have enough rep)

http://oi39.tinypic.com/2cxtez5.jpg

So My question is: how can I only show the values of the Books that u typed in the textfield.

  • 写回答

1条回答 默认 最新

  • douan9541 2013-08-12 10:24
    关注

    Seems to me, you don't pass the 'title' variable to your php-script.

    Try adding it via URLVariables as illustrated in this example:

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLVariables.html#includeExamplesSummary

    EDIT: OOPS, sorry, I guess you do! Overread it in the code above... Can you confirm the variable is passed in the php as it should be?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料