Topic: Web content disappears

There is a problem, I can not solve, the other person is not also encounter?
Website: http://shopping.24hour.com.tw/
The first time you open or refresh a few times, you will find the picture on the right is sometimes not displayed.
I use the 0.2.4 version, of course, also tested version 0.5, have the same problem.
0.5 version of the address is:
http://shopping.24hour.com.tw/test/

Re: Web content disappears

Hi,

I looked at your page and its source and am unable to see anything amiss. Perhaps you could post some source.

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

3 (edited by caterfillar 2014-04-02 6:55:10 AM)

Re: Web content disappears

look, i used template & xajax.

cl_index.php

<?
    include("mod.cl_main.php");
    include("mod.pg_product_function.php");
    class cl_index extends cl_main
    {

        function pgXajax()
        {
            //UserLogout
            $this->xajax->registerFunction(array("userLogout",$this,"userLogout"));
            //UserLogin
            $this->xajax->registerFunction(array("userLogin",$this,"userLogin"));
            //Change product list image
            $this->xajax->registerFunction(array("showListProductImage",$this,"showListProductImage"));
            //search product
            $this->xajax->registerFunction(array("productSearch",$this,"productSearch"));
            //other info
            $this->xajax->registerFunction(array("setPageInfo",$this,"setPageInfo"));
            $this->xajax->processRequests();
        }

        function pgValue()
        {
            $adArray=array(
                        "main"=>$this->page_dir."template/index.tpl",
                        "top"=>$this->page_dir."template/site_file/top.tpl",
                        "menu"=>$this->page_dir."template/site_file/menu_pd.tpl",
                        "foot"=>$this->page_dir."template/site_file/foot.tpl"
                    );
            $this->adTem->set_file($adArray);
            $this->clPageValue();
            $this->showProductSortList();
            $this->showProductList();
            $this->adTem->set_var($this->pg_xajax_js());
            $this->adTem->parse("pg_top","top");
            $this->adTem->parse("pg_pd_menu","menu");
            $this->adTem->parse("pg_foot","foot");
            $this->adTem->pparse("out","main");
        }

        function setPageInfo()
        {
                   //show right ad image list
            $this->showRightAdList();

            return $this->setInitPage();
        }
       
        function showProductList()
        {
            $productShowArea=setProductShowAreaArray();
            $productShowareaKey=setProductShowAreaKeyArray();
            $this->db->query("select * from `".TABLE_PRO_SORT."` where `s_id`='0' order by `s_order` limit 0 ,4");
            $r=0;
            while($sortData=$this->db->record())
            {
                $row=$r*4;
                $productListInfo.='<div class="abgne_tab">
                        <div>
                          <h1>'.$sortData['s_name'].'</h1>
                        </div>
                        <ul class="tabs">
                          <li><a href="#tab'.(1+$row).'">最新商品</a></li>
                          <li><a href="#tab'.(2+$row).'">暢銷商品</a></li>
                          <li><a href="#tab'.(3+$row).'">特價商品</a></li>
                          <li><a href="#tab'.(4+$row).'">商品出清</a></li>
                        </ul>
                        <div class="tab_container">';
                foreach($productShowArea as $k => $s)
                {
                    $n=1;
                    $showProductImg=$tbsProductList='';
                    $this->sDb->query("select * from `".TABLE_PRO."` where `p_ul_state`='1' and `p_mid`='".$sortData['id']."' and `p_show_area_".$productShowareaKey[$k]."` = '".$k."' order by rand() limit 0 ,5");
                    while($productData=$this->sDb->record())
                    {
                        $productItm=$productData['p_mid'].'.'.$productData['p_sid'].'.'.$productData['p_tid'].'.'.$productData['p_fid'].'.'.$productData['id'];
                        if($n==1)
                        {
                            $showProductImg='<a href="productDetail.php?itm='.$productItm.'"><img src="upload/product/'.$productData['p_img'].'" alt="" width="129" height="129" border="0" /></a>';
                        }
                        $tbsProductList.='<li><a href="productDetail.php?itm='.$productItm.'" onmouseover="xajax_showListProductImage(\''.$productData['id'].'\',\'productImage'.($k+$row).'\');">'.substrbig($productData['p_all_name'],44).'</a></li>';
                        $n++;
                    }
                    $productListInfo.=' <div id="tab'.($k+$row).'" class="tab_content">
                        <div class="tabs_img" id="productImage'.($k+$row).'">'.$showProductImg.'</div>
                        <div class="tabs_pdname">
                          <ul>'.$tbsProductList.' </ul>
                          <div class="more"><a href="productList.php?itm='.$k.'.'.$sortData['id'].'">more</a></div>
                        </div>
                      </div>';
                }
                $productListInfo.='</div></div>';
                $r++;
            }
            $this->adTem->set_var(array("productList"=>$productListInfo));
        }
       
        //show right ad image list
        function showRightAdList($pId=null,$showId=null)
        {
            $sql=" select * from `".TABLE_AD."` where `a_site`='2'   order by `a_order` ";
            $this->db->query($sql);
            $listInfo='';
            while ($res=$this->db->record())
            {
                $adUrl='javascript:void(null);';
                if(!empty($res['a_url'])) $adUrl=$res['a_url'];
                $listInfo.='<a href="'.$adUrl.'" target="_blank" ><img src="'.$this->page_dir.'upload/ad/'.$res['a_img'].'" alt="" width="208"  border="0" /></a>';
            }
            //$this->xajaxResponse->alert($listInfo);
            $this->xajaxResponse->assign('rightAdList','innerHTML',$listInfo);
        }

        function pg_xajax_js()
        {
            return array("xajax_js"=>$this->xajax->getJavascript($this->page_dir.'js/'));
        }
       
        function setInitPage($type=false)
        {
            if( session_is_registered("loginUser")  )
            {
                $userGradeArray=array("1"=>'A','2'=>'B','3'=>'C','4'=>'D','5'=>'E');
                $temp=' <p>'.$_SESSION['loginUser']['u_account'].',您好!<br />
                會員等級:'.$userGradeArray[$_SESSION['loginUser']['u_grade']].'</p>
                <p align="right" style="padding-bottom:8px"><a href="javascript:void(null);" onclick="xajax_userLogout();"><img src="image/web/btn_signout.gif" alt="" width="59" height="23" border="0" /></a></p>
  <div class="link"><a href="memberEdit.php">進入會員專區 &gt;&gt; </a></div>';
            }
            else
            {
                $temp='
               <form action="javascript:void(null);" method="post" name="userLoginForm" id="userLoginForm">
                        <p>帳 號
                          <input type="text" name="_User" id="_User" style="width:102px" />
                        </p>
                        <p>密 碼
                          <input type="password" name="_Pass" id="_Pass" style="width:102px" />
                        </p>
                        <p align="right"><a href="javascript:void(null);" onclick="login_submit();"> <image  src="image/web/btn_signin.gif" alt="" width="59" height="23" border="0" /></a></p>
                      </form>
                      <div class="link"><a href="join.php">加入會員</a><a href="find.php">忘記密碼</a></div> ';
            }
            $this->xajaxResponse->assign("indLoginUserInfo","innerHTML",$temp);
            return $this->xajaxResponse;
        }
       
    }
?>

Re: Web content disappears

Sorry I have not gotten back sooner.

First, before you get too far into xajax, please download version 0.5 and use it's syntax. You will find it mush eaasier to use. There are loads of sample php pages on the forum to go by.

This line;  $this->xajax->processRequests(); Should not be inside of a function. processRequest() is the main engine for xajax server side. You can put it anyplace in the php code outside of a function. One thing to be aware of is that any code - not functions - before the call to processRequest() will be executed every time the page loads. processRequest() intercepts the incoming request, calls the indicated function and returns the response from the function

You also need to place all of the registerFunction() outside of functions so that they are executed when the page loads.
Being inside of a function, they will not be called unless you call the function from somewhere on the page when it loads.

I like to place my register calls and processRequest call at the end of the php code.

In addition, you can register a class object using  this:

$tc = new cl_index();
$xajax->register(XAJAX_CALLABLE_OBJECT,$tc);

This registers all public functions in the class. You call them from the browser using xajax_cl_index.showProductList(). You would think you could register the class without an instance but xakax needs an object to work with.

<?
    include("mod.cl_main.php");
    include("mod.pg_product_function.php");
    class cl_index extends cl_main
    {
/*        function pgXajax() //No longer needed. Commentedout
        {
            //UserLogout
            $this->xajax->registerFunction(array("userLogout",$this,"userLogout"));
            //UserLogin
            $this->xajax->registerFunction(array("userLogin",$this,"userLogin"));
            //Change product list image
            $this->xajax->registerFunction(array("showListProductImage",$this,"showListProductImage"));
            //search product
            $this->xajax->registerFunction(array("productSearch",$this,"productSearch"));
            //other info
            $this->xajax->registerFunction(array("setPageInfo",$this,"setPageInfo"));
            $this->xajax->processRequests();
        }*/
        function pgValue()
        {
            $adArray=array(
                        "main"=>$this->page_dir."template/index.tpl",
                        "top"=>$this->page_dir."template/site_file/top.tpl",
                        "menu"=>$this->page_dir."template/site_file/menu_pd.tpl",
                        "foot"=>$this->page_dir."template/site_file/foot.tpl"
                    );
            $this->adTem->set_file($adArray);
            $this->clPageValue();
            $this->showProductSortList();
            $this->showProductList();
            $this->adTem->set_var($this->pg_xajax_js());
            $this->adTem->parse("pg_top","top");
            $this->adTem->parse("pg_pd_menu","menu");
            $this->adTem->parse("pg_foot","foot");
            $this->adTem->pparse("out","main");
        }
        function setPageInfo()
        {
                   //show right ad image list
            $this->showRightAdList();
            return $this->setInitPage();
        }
        
        function showProductList()
        {
            $productShowArea=setProductShowAreaArray();
            $productShowareaKey=setProductShowAreaKeyArray();
            $this->db->query("select * from `".TABLE_PRO_SORT."` where `s_id`='0' order by `s_order` limit 0 ,4");
            $r=0;
            while($sortData=$this->db->record())
            {
                $row=$r*4;
                $productListInfo.='<div class="abgne_tab">
                        <div>
                          <h1>'.$sortData['s_name'].'</h1>
                        </div>
                        <ul class="tabs">
                          <li><a href="#tab'.(1+$row).'">????</a></li>
                          <li><a href="#tab'.(2+$row).'">????</a></li>
                          <li><a href="#tab'.(3+$row).'">????</a></li>
                          <li><a href="#tab'.(4+$row).'">????</a></li>
                        </ul>
                        <div class="tab_container">';
                foreach($productShowArea as $k => $s)
                {
                    $n=1;
                    $showProductImg=$tbsProductList='';
                    $this->sDb->query("select * from `".TABLE_PRO."` where `p_ul_state`='1' and `p_mid`='".$sortData['id']."' and `p_show_area_".$productShowareaKey[$k]."` = '".$k."' order by rand() limit 0 ,5");
                    while($productData=$this->sDb->record())
                    {
                        $productItm=$productData['p_mid'].'.'.$productData['p_sid'].'.'.$productData['p_tid'].'.'.$productData['p_fid'].'.'.$productData['id'];
                        if($n==1)
                        {
                            $showProductImg='<a href="productDetail.php?itm='.$productItm.'"><img src="upload/product/'.$productData['p_img'].'" alt="" width="129" height="129" border="0" /></a>';
                        }
                        $tbsProductList.='<li><a href="productDetail.php?itm='.$productItm.'" onmouseover="xajax_showListProductImage(\''.$productData['id'].'\',\'productImage'.($k+$row).'\');">'.substrbig($productData['p_all_name'],44).'</a></li>';
                        $n++;
                    }
                    $productListInfo.=' <div id="tab'.($k+$row).'" class="tab_content">
                        <div class="tabs_img" id="productImage'.($k+$row).'">'.$showProductImg.'</div>
                        <div class="tabs_pdname">
                          <ul>'.$tbsProductList.' </ul>
                          <div class="more"><a href="productList.php?itm='.$k.'.'.$sortData['id'].'">more</a></div>
                        </div>
                      </div>';
                }
                $productListInfo.='</div></div>';
                $r++;
            }
            $this->adTem->set_var(array("productList"=>$productListInfo));
        }
        
        //show right ad image list
        function showRightAdList($pId=null,$showId=null)
        {
            $sql=" select * from `".TABLE_AD."` where `a_site`='2'   order by `a_order` ";
            $this->db->query($sql);
            $listInfo='';
            while ($res=$this->db->record()) 
            {
                $adUrl='javascript:void(null);';
                if(!empty($res['a_url'])) $adUrl=$res['a_url'];
                $listInfo.='<a href="'.$adUrl.'" target="_blank" ><img src="'.$this->page_dir.'upload/ad/'.$res['a_img'].'" alt="" width="208"  border="0" /></a>';
            }
            //$this->xajaxResponse->alert($listInfo);
            $this->xajaxResponse->assign('rightAdList','innerHTML',$listInfo);
        }
        function pg_xajax_js()
        {
            return array("xajax_js"=>$this->xajax->getJavascript($this->page_dir.'js/'));
        }
        
        function setInitPage($type=false)
        {
            if( session_is_registered("loginUser")  )
            {
                $userGradeArray=array("1"=>'A','2'=>'B','3'=>'C','4'=>'D','5'=>'E');
                $temp=' <p>'.$_SESSION['loginUser']['u_account'].',??!<br />
                ????:'.$userGradeArray[$_SESSION['loginUser']['u_grade']].'</p>
                <p align="right" style="padding-bottom:8px"><a href="javascript:void(null);" onclick="xajax_userLogout();"><img src="image/web/btn_signout.gif" alt="" width="59" height="23" border="0" /></a></p>
  <div class="link"><a href="memberEdit.php">?????? &gt;&gt; </a></div>';
            }
            else
            {
                $temp='
               <form action="javascript:void(null);" method="post" name="userLoginForm" id="userLoginForm">
                        <p>? ?
                          <input type="text" name="_User" id="_User" style="width:102px" />
                        </p>
                        <p>? ?
                          <input type="password" name="_Pass" id="_Pass" style="width:102px" />
                        </p>
                        <p align="right"><a href="javascript:void(null);" onclick="login_submit();"> <image  src="image/web/btn_signin.gif" alt="" width="59" height="23" border="0" /></a></p>
                      </form>
                      <div class="link"><a href="join.php">????</a><a href="find.php">????</a></div> ';
            }
            $this->xajaxResponse->assign("indLoginUserInfo","innerHTML",$temp);
            return $this->xajaxResponse;
        }
        
    }
    //New Code
    $ci = new cl_index();
    $xajax->register(XAJAX_CALLABLE_OBJECT, $ci)
?>

If there are methods you do not registered make them private or make the function name begin with an underscore.

Hope this helps smile

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: Web content disappears

I will test it, and then put the result tells you, thank you.