jQuery不会删除用户信息 [英] jQuery does not delete user info

查看:52
本文介绍了jQuery不会删除用户信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个php页面,该页面在删除数据之前使用jQuery进行确认,实际上,当我单击删除"时,它不执行任何操作,该链接也没有执行任何操作,我尝试了仍然没有任何反应,请协助我

I have a php page that uses a jQuery to confirm before deleting data, Infact when I click delete it doesnt do anything the link doesnt do anything, I tried my efforts still nothing happens, please assist me

我的代码 Teacher.php

my code teacher.php

    <?php
    require_once('../auth.php');
?>
<html>
<head>
<title>Silay Institute</title>
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
<!--sa poip up-->
<link href="src/facebox.css" media="screen" rel="stylesheet" type="text/css" />
   <script src="lib/jquery.js" type="text/javascript"></script>
  <script src="src/facebox.js" type="text/javascript"></script>
  <script type="text/javascript">
    jQuery(document).ready(function($) {
      $('a[rel*=facebox]').facebox({
        loadingImage : 'src/loading.gif',
        closeImage   : 'src/closelabel.png'
      })
    })
  </script>
    <link rel="stylesheet" href="febe/style.css" type="text/css" media="screen" charset="utf-8">
<script src="argiepolicarpio.js" type="text/javascript" charset="utf-8"></script>
<script src="js/application.js" type="text/javascript" charset="utf-8"></script>
<style>
#mainhhh {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 8px solid #EEEEEE;
    border-radius: 5px 5px 5px 5px;
    box-shadow: 0 0 10px #4E707C;
    font: 11px "Trebuchet MS",Verdana,Arial,Helvetica,sans-serif;
    margin: 5em auto;
    position: relative;
    text-align: left;
    width: 1000px;
}
#mainhhh h1 {
    background: none repeat scroll 0 0 #0092C8;
    border-bottom: 1px solid #007DAB;
    color: #FFFFFF;
    font-size: 14px;
    margin: 0;
    padding: 5px 10px;
    text-shadow: 0 1px 0 #007DAB;
}
</style>    
</head>
<body>
<div id="mainhhh">
<h1>
<a id="addq" href="index.php" title="click to enter homepage" style="background-image:url('../images/out.png'); background-repeat:no-repeat; padding: 3px 12px 12px; margin-right: 10px;"></a>
<label for="filter">Filter</label> <input type="text" name="filter" value="" id="filter" />
    <a rel="facebox" href="addteacher.php" id="addq">Add Teacher</a>

</h1>

        <table cellpadding="1" cellspacing="1" id="resultTable">
            <thead>
                <tr>
                    <th  style="border-left: 1px solid #C1DAD7"> Name </th>
                    <th>ID Number</th>
                    <th>Work</th>
                    <th>Gender</th>
                    <th>Status</th>
                    <th>Birthday</th>
                    <th>Advisory</th>
                    <th> Action </th>
                </tr>
            </thead>
            <tbody>
            <?php
                include('../connect.php');
                $result = mysql_query("SELECT * FROM teacher");
                while($row = mysql_fetch_array($result))
                    {
                        echo '<tr class="record">';
                        echo '<td  style="border-left: 1px solid #C1DAD7">'.$row['fname'].' '.$row['mname'].' '.$row['lname'].'</td>';
                        echo '<td><div align="left">'.$row['idnumber'].'</div></td>';
                        echo '<td><div align="left">'.$row['work'].'</div></td>';
                        echo '<td><div align="left">'.$row['gender'].'</div></td>';
                        echo '<td><div align="left">'.$row['status'].'</div></td>';
                        echo '<td><div align="left">'.$row['bday'].'</div></td>';
                        echo '<td><div align="left">';
                        $sdsd=$row['idnumber'];
                        $results = mysql_query("SELECT * FROM `teacher` JOIN `advisory` ON `advisory`.`tid`=`teacher`.`idnumber`");
                            while($rows = mysql_fetch_array($results))
                                {
                                echo $rows['level'].' section '.$rows['section'];
                                }
                        echo '</div></td>';
                        echo '<td><div align="center"><a rel="facebox" href="editprofile.php?id='.$row['id'].'" title="Click To Edit">Edit Profile</a> | <a href="#" id="'.$row['id'].'" class="delbutton" title="Click To Delete">delete</a></div></td>';
                        echo '</tr>';
                    }
                ?> 
            </tbody>
        </table>
</div>  
<script src="js/jquery.js"></script>
  <script type="text/javascript">
$(function() {


$(".delbutton").click(function(){

//Save the link in a variable called element
var element = $(this);

//Find the id of the link that was clicked
var del_id = element.attr("id");

//Built a url to send
var info = {'id': del_id};

 if(confirm("Sure you want to delete this update? There is NO undo!"))
          {

 $.ajax({
   type: "GET",
   url: "deleteteacher.php",
   data: info,
   success: function(){

   }
 });
         $(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
        .animate({ opacity: "hide" }, "slow");

 }

return false;

});

});
</script>
</body>
</html>

deleteteacher.php

deleteteacher.php

<?php

// This is a sample code in case you wish to check the username from a mysql db table
include('../connect.php');
if($_GET['id'])
{
$id = intval($_GET['id']); 
 $sql = "delete from teacher where id='$id'";
 mysql_query( $sql);
}

?>

推荐答案

我记得,您应该将JSON对象作为数据发送;这意味着您应该制作字典,而不仅仅是作业.当您编写$_GET['id']时,编译器会使用键"id"在数据字典中搜索元素,以返回其值;但是由于您不发送字典结构化数据,因此它返回NULL,当然不会发生任何事情.

As I remember, you should send a JSON object as data; its means you should make a dictionary, not just an assignment. When you write $_GET['id'] compiler searches for an element in the data dictionary with key "id" to returns its value; but since you don't send a dictionary structured data, it returns NULL and of course nothing will happen.

您应该在删除函数中编写如下内容:

You should write something like this in your delete function:

var info = {'id': del_id};

这篇关于jQuery不会删除用户信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆