Show file info at mouseover with Ajax and PHP

Hi
I have a list of files made by my PHP code

Code:


    if ($handle = opendir($director)) 
    {
        $path="http://tycoontalk.freelancer.com/images/files/nou/";
        if(Files::is_empty_dir($director))
            {
                echo "<p>There are no script available.</p>";
            }
        else
            {
      while (false !== ($file = readdir($handle)))
      {
            if ($file != "." && $file != "..")
                {
            $size=Files::getSize($director."/".$file);
            $exts=Files::getExtension($file);
                    $filex = str_replace(".".$exts,"",$file);
                if(strlen($filex)>10)
                    {
                        $filex=substr($filex,0,6);
                    }
                    echo "<div class='file' title='".$file."'>".$filex."</div>";


There are functions defined in my own class "Files".
Good. I want that on mouseover to show file information with this code

Code:


    function getInfo($file)
            {
                $info="<div class='info_public'><table border=0 cellpadding=2><tr>";
                $info.="<td>File : </td><td>".$file."</td></tr>";
                $info.="<tr><td>Extension : </td><td>".Files::getExtension($file)."</td></tr>";
                $info.="<tr><td>Size : </td><td>".Files::getSize($file)."</td></tr>";
               
                return $info;
            }


I want to show info dynamically with JQuery. I wrote this

Code:

$(function() {
    $(".file").mouseover(function()
        {
            data=$(this).attr("title");
            alert(data);
        });
});


It alerts always first filename not what I mouseover. But if I quit to use mouseover JQuery function, the title appears correctly for each file in part. If I use mouseover function again, the selected value from title doesn’t appear correctly, it shows first filename in alert no matter what file I crossed with mouse.

I called the alert function to see results before implementing $.ajax function to avoid bad responses.
What’s the problem in my script ?

Thank you

View full post on Tycoon Talk

, , , ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes


RSS Site FeedRSS Site Feed

© 1992-2011 DC2NET™, Inc. All Rights Reserved