Search code examples
phpajaxprototypejs

refresh the div tag on click of the delete record


i'm using the prototype.js , PDO , PHP. i want to delete the records with refresh using ajax

index.php

     <?php if(!isset($studentVoList)||count($studentVoList)==0){?>
        <tr><td colspan="3" align="center">No records found.</td></tr>
        <?php } else {
            foreach($studentVoList as $studentVo) {
        ?>
        <tr>
        <td align="center"><?php echo $studentVo->id;?></td>
        <!--td align="center"><?php echo "1";?></td-->
        <td>
        <Select NAME="CoId" >
            <Option VALUE="Item1">1</option>
            <Option VALUE="Item2">2</option>
            <Option VALUE="Item3">3</option>
        </Select>


        </td>
        <td align="center"><?php echo $studentVo->st_name;?></td>
        <td align="center"><?php echo $studentVo->st_city;?></td>
        <td align="center"><?php echo $studentVo->st_created;?></td>
        <td align="center"><?php echo $studentVo->st_modified;?></td>

        <td align="center">
        <a href="javascript: submitForm('<?php echo $studentVo->id?>','view')">Edit</a></td>
        <td align="center">
        <!--a href="javascript: submitForm('<?php //echo $studentVo->id?>','delete')">Delete</a></td-->
        <a href="javascript: deleteId('<?php echo $studentVo->id?>')">Delete</a></td>

        </tr>
        <?php 
        }
        }
       ?>

script is

     function deleteId(id){

     alert("Id:="+id);
      var myAjax = new Ajax.Request('delete.php',{method:'post',parameters: 'action='+ id});

    }

delete is done but after i refresh , i want to refresh the code on click the of delete button


Solution

  • You can get some ideas from this tutorial http://papermashup.com/jquery-ajax-delete/ Or, if you are using jquery, simply use the plugin