Results 1 to 6 of 6

Thread: Flex Menu called via Ajax

  1. #1
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Flex Menu called via Ajax

    1) Script Title: Flex Level Drop Down Menu (v1.1)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...exdropdown.htm

    3) Describe problem:
    I am trying to run this in a php file (to read MSQL) which has already been called
    by Ajax

    Code:
    // Customise those settings
    
    var seconds = 15;
    var divid = "timediv";
    var url = "afc21t.php";
    
    ////////////////////////////////
    //
    // Refreshing the DIV
    //
    ////////////////////////////////
    
    function refreshdiv(){
    
    // The XMLHttpRequest object
    
    var xmlHttp;
    try{
    xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
    }
    catch (e){
    try{
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
    }
    catch (e){
    try{
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e){
    alert("Your browser does not support AJAX.");
    return false;
    }
    }
    }
    
    // Timestamp for preventing IE caching the GET request
    
    fetch_unix_timestamp = function()
    {
    return parseInt(new Date().getTime().toString().substring(0, 10))
    }
    
    var timestamp = fetch_unix_timestamp();
    var nocacheurl = url+"?t="+timestamp;
    
    // The code...
    
    xmlHttp.onreadystatechange=function(){
    if(xmlHttp.readyState==4){
    document.getElementById(divid).innerHTML=xmlHttp.responseText;
    setTimeout('refreshdiv()',seconds*1000);
    }
    }
    xmlHttp.open("GET",nocacheurl,true);
    xmlHttp.send(null);
    }
    
    // Start the refreshing process
    
    var seconds;
    window.onload = function startrefresh(){
    setTimeout('refreshdiv()',seconds*1000);
    }
    to allow updated user data to be retrieved before putting into the flex menu

    it appears to be clashing somewhere - but I can't work out where!

    no errors are reported - it just does nothing

    any ideas?

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm we need to see the rest of the page to know what the issue might be. Please post a link to the page on your site that contains the problematic script so we can check it out.
    DD Admin

  3. #3
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi

    The main site is http://alderneyfriends.com -- you will need to login to see the popdown menu working (v1.0) usename and password = guest

    I the files I am using to test this are

    http://alderneyfriends.com/afc21x.php and

    http://alderneyfriends.com/afc21t.php

    afc21x calls afc21t via the ajax.js I posted last time

    code for afc21x.php
    Code:
    <?php
    echo '<script src="ajax.js"></script>
    
    <strong>Testing Updates</strong>
    ';
    
    echo '
    <script type="text/javascript"><!--
    refreshdiv();
    // --></script>
    
    <div id="timediv"></div>' ;
    echo "after the test" ;
    ?>
    code for afc21t.php

    Code:
    <?php
    $db_server = 'localhost';
    $db_name = 'alderneyfriends';
    $db_user = 'alderneyfriends';
    $db_passwd = '********';
    mysql_connect($db_server,$db_user,$db_passwd);
    @mysql_select_db($db_name) or die( "Unable to select board database");
    echo '
    <link rel="stylesheet" type="text/css" href="flexdropdown.css" />
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    
    <script type="text/javascript" src="flexdropdown.js">
    
    /***********************************************
    * Flex Level Drop Down Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
    ***********************************************/
    
    </script> ';
    
    
    
    
    
    
     if (isset($_COOKIE[aldfriendu])) {
                  $user1 = $_COOKIE[aldfriendu] ;
    
    echo "$user1 ****<br> ".date('H:i:s')."<br>" ;
    $timeon = time() ;
    $query1 = "UPDATE users SET laston = '$timeon' WHERE user = '$user1' " ;
    mysql_query($query1) ;   }
    
    $timeon = time() - 30 ; // 30 seconds ago
    $query1 = "SELECT user,doing FROM users WHERE laston > '$timeon' ";
    $result = mysql_query($query1) ;
    
    $friends = mysql_num_rows($result) ;
    
    echo "<span class='p8 b1'>" .$friends . " Friends online : </span><br> " ;
    $frol = ""  ;
    
    
    while ($row = mysql_fetch_array($result))
    {  // $doing=unfixquote($row[doing]);
    user_menu($row[user],'online','','online1') ;
    if ($friends < 10 ) echo "<br>"; else echo " " ;
    }
    
    echo "</center>" ;
    
    ///////// functions start here
    //////////////////////////////////////////////////////////////////////////
    
    
    function unfixquote($a,$b="0")
    
       { global $afc ;
          global $islandname ;
          global $afcweb ;
          $a = htmlspecialchars_decode($a) ;
        $a=str_replace("&lt;","<",$a) ;
        $a=str_replace("&gt;",">",$a) ;
        $a=str_replace("\n","<br>",$a) ;
        $a=str_replace("\r","<br>",$a) ;
        $a=str_replace("<P>","",$a) ;
        $a=str_replace("</P>","",$a) ;
        $a=str_replace('AUTOSTART="1"','AUTOSTART="0"',$a) ;
        $a=str_replace('<PARAM NAME="autoStart" VALUE="-1">','<PARAM NAME="autoStart" VALUE="0">',$a) ;
        $a=str_replace('height=288 w','height=288 declare=declare w',$a) ; // stops items pasted from ctv auto loading -- speeds up news page 
        $a=str_replace('src=/sharedscripts/','src=http://www.channelonline.tv/sharedscripts/',$a) ;
        $a=str_replace('****','f**k',$a) ; 
        $a=str_replace('****','c**t',$a) ; 
        $a=str_replace('****','s**t',$a) ; 
         $a=str_replace('****','F**K',$a) ; 
        $a=str_replace('****','C**T',$a) ; 
        $a=str_replace('****','S**T',$a) ; 
         $a=str_replace('****','F**k',$a) ; 
        $a=str_replace('****','C**t',$a) ; 
        $a=str_replace('****','S**t',$a) ; 
        $a=str_replace('$afcweb',$afcweb,$a) ;
        $a=str_replace('$afc',$afc,$a) ;
        $a=str_replace('$island',$islandname,$a) ;
        $a=str_replace("<p>","<br>",$a) ;
        $a=str_replace("</p>","<br>",$a) ;
        $a=str_replace("<BR>","<br>",$a) ;
        $a=str_replace("DIV>","div>",$a) ;
        $a=str_replace("<div><br></div>","<br>",$a) ;
        $a=str_replace("<br><br><br><br>","<br>",$a) ;
        $a=str_replace("<br><br><br>","<br>",$a) ;
        $a=str_replace("<br><br>","<br>",$a) ;
    
         return $a;
        }
    
        function display_avatar($name,$small=0,$nolink=0)
    {
    
    global $avatar ;
    global $userrow ;
    
    if (!$name) {$name = "newsfeed" ; $nolink = 1 ;}
    $avatar = "timages/thumbs/".$name.".jpg" ;
    if (!file_exists($avatar)) $avatar = "timages/thumbs/no_image.jpg" ;
    
    
    $avatar1 = $avatar ; //. "?e=".time() ;
    if ($nolink == 0 ) {
    $title = "View profile for $name" ;
    echo "<a href=index.php?mode=96&user=$name  title='$title' >" ; }
    if ($small != 1)
    {echo "<img src=$avatar1 border=0 />" ; }
    else
    {
    if ($userrow[bigtext] == 1)
    {  echo "<img src=$avatar1 width=45 scalefit=1 border=0 />" ; }
    elseif ($userrow[bigtext] == 2)
    {  echo "<img src=$avatar1 width=60 scalefit=1 border=0 />" ; }
    else
    {  echo "<img src=$avatar1 width=30 scalefit=1 border=0 />" ; }
    }
    if ($nolink == 0 ) echo "</a>" ;
    }
    
    function user_menu($user_name,$class='',$doing='',$class2='b0')
    {
    global $mode;
    $query="SELECT laston FROM users WHERE user='$user_name'";
    
    
    $menuname = $username . rand() ;
    echo "<span class='$class'><a href='#' data-flexmenu='$menuname' >
    <span class='$class2'>$user_name</a></span></span> ";
    echo "<ul id='$menuname' class='flexdropdownmenu'>" ;
    echo "<li>" ;
    display_avatar($user_name,1,1);
    $a = strlen($user_name) ;
    switch ($a) {
           case ($a > 15) :  echo "<br><span class=b0>$user_name</span></li>" ;
           break;
           case ($a > 10) : echo "<br><span class=b0>$user_name</span></li>" ;
           break ;
           default : echo " <span class=b0>$user_name</span></li>" ;
           }
    //if ($doing) {
    //echo "<span class=vsmall>$doing</span>" ;}
    echo "<li><a href='index.php?mode=96&user=$user_name' target='_top' >View Profile</a></li>";
    
    // echo "<li><a href='#'>Send a Quick ....";
    // echo "<ul id='$menuname' class='jqpopupmenu'>";
    echo "<li><a href='index.php?mode=$mode&sendhi=$user_name&hype=1'  target='_top' >Say Hi</a></li>" ;
    
    if (date('H') < 12) echo "<li><a href='index.php?mode=$mode&sendhi=$user_name&hype=6' target='_top'  >Say Good Morning</a></li>";
    if (date('H')  > 11 && date('H') < 18) echo "<li><a href='index.php?mode=$mode&sendhi=$user_name&hype=7'  target='_top'  >Say Good Afternoon</a></li>";
    if (date('H') > 17) echo "<li><a href='index.php?mode=$mode&sendhi=$user_name&hype=8'  target='_top' >Say Good Evening</a></li>";
    if (date('H') < 4 || date('H') > 21) echo "<li><a href='index.php?mode=$mode&sendhi=$user_name&hype=9' target='_top'  >Say Good Night</a></li>";
    
    
    
    echo "<li><a href='index.php?mode=$mode&sendhi=$user_name&hype=2' target='_top'  >Send a Nudge</a></li>";
    echo "<li><a href='index.php?mode=$mode&sendhi=$user_name&hype=3' target='_top'  >Send a Poke</a></li>";
    echo "<li><a href='index.php?mode=$mode&sendhi=$user_name&hype=4'  target='_top' >Send a Hug</a></li>";
    echo "<li><a href='index.php?mode=$mode&sendhi=$user_name&hype=5'  target='_top' >Send a Wink</a></li>";
    // echo "</ul></li>";
    echo "<li><a href='index.php?mode=5&user=$user_name#newa'  target='_top' >Send Message </a></li>";
    echo "<li><a href='index.php?mode=25&user=$user_name'  target='_top' >View Blog</a></li>";
    echo "<li><a href='index.php?mode=96&user=$user_name#hist' target='_top'  >View Status History</a></li>";
    echo "</ul>";
    }
    
    ?>

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    I've managed to log in. Which flex menu is the one being dynamically fetched and is showing blank instead?
    DD Admin

  5. #5
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi

    It you go to http://alderneyfriends.com/afc21x.php there are dynamic menus on the 'names'

    if you go to http://alderneyfriends.com/afc21t.php the menus work

    (afc21x.php calls afc21t.php via the ajax.js )

    hope it is clear, if not you can chat with me on http://alderneyfriends.com

    I am admin!

  6. #6
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi

    I think I have found the problem

    JavaScript does not work within php/html files called by xmlHttp.open

    Regards

    Paul

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •