Jump to content

javascript function doesnt run


etsted
 Share

Recommended Posts

any reason to why

if($username == $u){                        $deleteBtn = '<a href="#" onclick="return false" onmousedown="delete('file_'.$id.'',''.$db_table.'')">Delete</a>';                    }

function wont run?

function db_table($queryAgainst, $db_table){            global $con; global $output; global $u;            $query = mysqli_query($con, $queryAgainst) or die(mysqli_error($con));         while($row = mysqli_fetch_array($query)){                                $id = $row['id'];                    $title = $row['tittel'];                    $description = $row['description'];                    $username = $row['username'];                    $file_url = $row['file_url'];                    $upload_date = $row['upload_date'];                    $avatar = $row['avatar'];                                        // give their files an avatar , if they dont already have one                    if($avatar == NULL)                        {                            $avatar = "images/avatardefault.png";                        }                        else                        {                            $avatar = "user/$username/$avatar";                        }                    $file_url = explode(".", $file_url);                                        // give the owner                    if($username == $u){                        $deleteBtn = '<a href="#" onclick="return false" onmousedown="delete('file_'.$id.'',''.$db_table.'')">Delete</a>';                    }                        $output .= '<div id="file_'.$id.'" class="files" style="background: #37ff37; width:250px; color: black; float: left; margin: 3px;">                                           <a href="watch.php?f='.$file_url[0].'"><img src="'.$avatar.'" height="80" width="85" alt="'.$title.'"> Watch</a>                                                                                       '.$deleteBtn.'                                         <br>                                         <div style="overflow:hidden; text-overflow:ellipsis; ">Tittel: '.$title.'</div>                                         <br>                                         <span>Uploaded by: <a href="user.php?u='.$username.'">'.$username.'</a></span>                                         <br>                                         <div style=" overflow: hidden; word-wrap:break-word; height:60px;">Description: '.$description.' </div>                                         <br>                                         <span>Upload date: '.$upload_date.'</span>                                         <br>                                       </div>' . "nn";         }        }        db_table($videos, "videos");        db_table($images, "images");        db_table($mp3, "mp3");

The javascript that correspond

<script>function delete(fileId,db_table){    var ajax = ajaxObj("POST", "php_parsers/usersFiles_system.php");    alert("hi");    ajax.onreadystatechange = function() {        if(ajaxReturn(ajax) == true) {            if(ajax.responseText == "delete_ok"){                                // remove the div all of the tekst is inside, the textarea and the reply button                _(fileId).style.display = 'none';            } else {                alert(ajax.responseText);            }        }    }    ajax.send("action=delete_file&db_table="+db_table+"&file_id="+fileId);}</script>
Link to comment
Share on other sites

what happens instead? are you checking for errors in the console? any sort of debugging / logging to trace the execution of your code?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...