Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $(document).ready(function() {
- /* load table with page load*/
- $("#sort tbody").load("inc/index_table.php");
- /* row deletion */
- $(".deletelink").click(function(){
- var id = $(this).attr("id");
- $.ajax({
- beforeSend: function (request) {
- var answer = confirm("Are you SURE you want to delete this?/nThis action is NOT reversible.")
- if (answer){ return(true); }
- else { return(false); }
- },
- type: "POST",
- url: location.href,
- data: "delete="+id,
- error: function() {
- console.log("Theres an error with AJAX deletion");
- },
- success: function(){ //a.td.tr.remove just that row rather than the whole table
- $this.parent().parent().remove();
- console.log("Deleted.");
- }
- });
- });
- });
- </script>
- $("#sort tbody").load("inc/index_table.php");
- /* row deletion */
- $("#sort tbody").on("click", ".deletelink", function(){
- //...rest of code the same
- });
- $("#sort tbody").load("inc/index_table.php");
- $("#sort tbody").delegate(".deletelink", "click", function(){
- //...rest of code the same
- });
- $("#sort tbody").load("inc/index_table.php", function(){
- /* row deletion */
- $(".deletelink").click(function(){
- // .. your code as before.
- });
- });
- $("#sort tbody").load("inc/index_table.php", function() {
- /* row deletion */
- $(".deletelink").click(function(){ ....
- });
- });
- $(".deletelink").on('click',function(e){
- e.preventDefault();
- $(".deletelink").live('click',function(){
- // ajax call handling code here
- });
Add Comment
Please, Sign In to add comment