0

私はいくつかの出力を与えるphpからコンソールアプリケーションを呼び出しています。コンソール アプリケーションの実行後に、出力を div に表示する必要があります。コンソール アプリケーションからの出力を SESSION として別のページに渡して表示しました。Web ページでも ajax と JavaScript を使用しているため、より複雑になっています。出力を印刷すると、div の出力は SESSION の前の値になります。私のコードは次のとおりです。

メインページ:

<!DOCTYPE html>
<html>
    <head>

                    $('#file').live('change', function()    
                    { 
                    $("#preview").html('');
                    $("#preview").html('<img src="images/loader.gif" alt="Uploading...."/>');
                    $("#imageform").ajaxForm(
                    {
                    target: '#preview'
                    }).submit();

                    <script type="text/javascript">
                    function myfunction()
                    {
                    $("#display").html('');
                    $("#display").html('<img src="images/loader.gif" alt="Uploading...."/>');
                    $("#retrieveimageform").ajaxForm(
                    {
                    target: '#display'
                    }).submit();

                     $('#tags').html('<?php include 'Tagsdisplay.php';?>');  
 %I want to include this only after it goes through the retrieveimage1.php page
 where the console application is called and the session is created but this is
 not happening the tags div is shown before the console application is called 
 and the other results are displayed on the display div
                     $('#tags').show();
                    };


                    </script>

        <title></title>
    </head>
    <body>
        <div id="maindiv">
                <div id="banner">
                <?php
                include 'Header.php';

                ?>
                 </div>
                <div id="wrapper">

                        <div id="imageupload">
                    <form action="uploadimage.php" method="post"
                         enctype="multipart/form-data" id="imageform">
                         <label for="file">Upload your image:</label>
                       <input type="file" name="file" id="file"><br>

                    </form>
                        </div>
                       <div id='preview'>  
                        </div>
                    <div id='tags'>

                    </div>

                       <div class="clear"></div>

                    <form action="retrieveimage1.php" method="post"
                           id="retrieveimageform">

                       ................................   

                         <input type="submit" name="search" value="Search" id="btnSearch" onclick="myfunction()">

                    </form>
     <div id="display"></div>

                 </div>

コンソール アプリが呼び出され、セッションが作成される retrieveimage.php:

          session_start();
          $start_time=  microtime(true);
        if (isset($_SESSION['img']))
        {   
                $image=$_SESSION['img'];
                $_SESSION['coarselbl1']=" ";
                $_SESSION['coarselbl2']=" ";
                $_SESSION['coarselbl3']=" ";
                $_SESSION['finelbl1']=" ";
                $_SESSION['finelbl2']=" ";
                $_SESSION['finelbl3']=" ";
                $_SESSION['finelbl4']=" ";
                $_SESSION['category']=" ";
                    if($_POST['cat']=='handbag')
                            {
                                 $_SESSION['category']="Bag";
                                 $cwt=$_POST["slider1"];
                                $fwt=$_POST["slider2"];
                                $twt=$_POST["slider3"];
                                $swt=$_POST["slider4"];

                                $addr="handbags31_fourth.exe $image $cwt $fwt $swt $twt";
                                  exec($addr,$data);

                                  $_SESSION['coarselbl1']=$data[2];
                                  $_SESSION['coarselbl2']=$data[3];
                                  $_SESSION['coarselbl3']=$data[4];
                   }

タグが表示される TagsDisplay.php:

<?php
        session_start();
        echo $_SESSION['category']."<br/>";
   if($_SESSION['category']=="Bag")
    {
        echo "Coarse Color:   ".$_SESSION['coarselbl1'].",".$_SESSION['coarselbl2'].",".$_SESSION['coarselbl3']."<br/>";
        unset($_SESSION['coarselbl1']);
        unset($_SESSION['coarselbl2']);
        unset($_SESSION['coarselbl3']);


    }


?>

ここでの問題は、検索ボタンをクリックすると myfunction が呼び出され、表示 div の前にタグ div が表示され、出力された値が前のセッション値になることです。表示 div が表示され、新しいセッションが割り当てられた後にのみ、タグ div が来るようにします。どうすればそれを達成できますか?

4

1 に答える 1

0

jquery の行を修正する

$('#tags').html('<?php include 'Tagsdisplay.php';?>'); 

これに:

$('#tags').html('<?php include "Tagsdisplay.php";?>'); 

(引用符に注意してください)前のセッションの値を設定解除するファイルを含めていないためです。

于 2013-06-11T05:37:02.023 に答える