Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:59:28+00:00 2026-06-10T00:59:28+00:00

Using this example: http://www.w3schools.com/php/php_ajax_database.asp I have set up a table echoing from database. I

  • 0

Using this example: http://www.w3schools.com/php/php_ajax_database.asp
I have set up a table echoing from database.

I am now trying to initiate datatables plugin on the table, everything is set up correctly but it wont work. I have tried to initiate the datatable in the html and the php pages but neither seem to work.

I am similarly having the same problem incorporating this example:
http://davidwalsh.name/animated-ajax-jquery

Is it this bit from the first example causing the issue as the page has already loaded before xmlhttp.open and xmlhttp.send(); is sent.

 xmlhttp.open("GET","getuser.php?username="+username+"&year="+str,true);
 xmlhttp.send();

head

        $(document).ready(function() {
      $('a.delete').click(function(e) {
        e.preventDefault();
        var parent = $(this).parent();
        $.ajax({
          type: 'get',
          url: 'jquery-record-delete.php',
          data: 'ajax=1&delete=' + parent.attr('id').replace('record-',''),
          beforeSend: function() {
            parent.animate({'backgroundColor':'#fb6c6c'},300);
          },
          success: function() {
            parent.slideUp(300,function() {
              parent.remove();
            });
          }
        });
      });
    });

        jQuery( function( $ ) {// Implements the dataTables plugin on the HTML table
var $adtTable= $("#academic_days_table").dataTable({
        "iDisplayLength": 30,       
        "sDom": '<"clear">t>',
        "aaSortingFixed": [[0,'asc']],
        "aoColumns": [
            { "bSortable": false },
            { "bSortable": false },
            { "bSortable": false },
            { "bSortable": false }
            ]
});

    });

HTML page

 function showUser(str, username)
 {
 if (str=="")
   {
   document.getElementById("department_logs_txtHint").innerHTML="";
   return;
   } 
 if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
   }
 else
   {// code for IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
 xmlhttp.onreadystatechange=function()
   {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
     document.getElementById("department_logs_txtHint").innerHTML=xmlhttp.responseText;
     }
   }
 xmlhttp.open("GET","getuser.php?username="+username+"&year="+str,true);
 xmlhttp.send();
 } 

<form>
    <select id="employee_user">
    <option value="">--</option>  
</select>

<select id="they" onchange="showUser(this.value, employee_user.value)">
<option value="">--</option>

    </select>
</form>

php page

<?php
include_once("scripts/connection.php");

$year = $_GET["year"];
$username = $_GET["username"];

$is_academic_result = mysql_query('SELECT * FROM holiday_entitlement_academic WHERE employee = \'' . $username . '\' AND academic_year = \'' . $year . '\' ');

if($is_academic = mysql_fetch_array($is_academic_result)) {

echo'<div style="float:left; width:400px;">';

echo'<table width="100%">
<tr>
<td><strong>Name:</strong></td>
<td>'.$is_academic['employee'].'</td>
</tr>
<tr>
<td><strong>Entitlement:</strong></td>
<td>'.$is_academic['entitlement'].' '.$is_academic['units'].'</td>
</tr>
<tr>
<td><strong>Department / Division:</strong></td>
<td>'.$is_academic['division'].'</td>
</tr>
<tr>
<td><strong>Line Manager:</strong></td>
<td>'.$is_academic['line_manager'].'</td>
</tr>
</table>';
echo'<br/>';

echo'</div>';


echo'<table class="dataTable" id="academic_days_table" cellpadding="2" cellspacing="2" width="100%">
<thead>
<th>Start Date</th>
<th>End Date</th>
<th>'.$is_academic['units'].' to be taken</th>
<th>'.$is_academic['units'].' remaining</th>
<th></th>
</thead>';

echo '<tr>';

echo '<td>-</td>';
echo '<td>-</td>';
echo '<td>-</td>';
echo '<td>'.$is_academic['entitlement'].'</td>';
echo '<td></td>';

echo '</tr>';


$input = $is_academic['entitlement'];
}

else {echo 'You currently dont have a record for this academic year. ';}


//$requests_result = mysql_query('
//SELECT * 
//FROM holiday_entitlement_business_manual
//LEFT JOIN requests ON holiday_entitlement_business_manual.employee = requests.employee
//WHERE employee = \'' . $username . '\' AND academic_year = \'' . $acyear . '\' ');


$requests_result = mysql_query('SELECT * FROM requests WHERE employee = \'' . $username . '\' AND approved = 1 AND academic_year = \'' . $year . '\' ORDER BY start_date ASC');

$remainder = 0;

while($requests = mysql_fetch_array($requests_result)) {

$remainder = ($remainder == 0) ? $input : $remainder;
$out = $remainder - $requests['days'];
if($out < 0){
      break;
}
$remainder = $out;


echo'<tr>';
echo'<td>'.$requests['start_date'].'</td>';
echo'<td>'.$requests['end_date'].'</td>';
echo'<td>'.$requests['days'].'</td>';
echo'<td>'.$remainder.'</td>';
echo'<td><a href="?delete='.$requests['id'].'" class="delete"><img src="images/cross.png"></a></td>';
echo'</tr>';
}

echo'</table>';

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:59:29+00:00Added an answer on June 10, 2026 at 12:59 am

    include the script in xmlhttp.onreadystatechange=function()

    Datatables is now loaded and $(‘a.delete’).click(function(e) {} is working

    Here is an example:

     function showUser(str, username)
     {
     if (str=="")
       {
       document.getElementById("department_logs_txtHint").innerHTML="";
       return;
       } 
     if (window.XMLHttpRequest)
       {// code for IE7+, Firefox, Chrome, Opera, Safari
       xmlhttp=new XMLHttpRequest();
       }
     else
       {// code for IE6, IE5
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
       }
     xmlhttp.onreadystatechange=function()
       {
       if (xmlhttp.readyState==4 && xmlhttp.status==200)
         {           
         document.getElementById("department_logs_txtHint").innerHTML=xmlhttp.responseText;
         $('#business_days_table').dataTable({
            "iDisplayLength": 30,       
            "sDom": '<"clear">t>',
            "aaSortingFixed": [[0,'asc']],
            "aoColumns": [
                { "bSortable": false },
                { "bSortable": false },
                { "bSortable": false },
                { "bSortable": false },
                { "bSortable": false }
                ]
         });    
         $('#academic_days_table').dataTable({
            "iDisplayLength": 30,       
            "sDom": '<"clear">t>',
            "aaSortingFixed": [[0,'asc']],
            "aoColumns": [
                { "bSortable": false },
                { "bSortable": false },
                { "bSortable": false },
                { "bSortable": false },
                { "bSortable": false }
                ]
         });
      $('a.delete').click(function(e) {
        e.preventDefault();
        var parent = $(this).parent();
        $.ajax({
          type: 'get',
          url: 'getuser.php',
          data: 'ajax=1&delete=' + parent.attr('id').replace('record-',''),
          beforeSend: function() {
            parent.animate({'backgroundColor':'#fb6c6c'},300);
          },
          success: function() {
            parent.slideUp(300,function() {
              parent.remove();
            });
          }
        });
      });
    
         }
       }
    
     xmlhttp.open("GET","getuser.php?username="+username+"&year="+str,true);
     xmlhttp.send();
     } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this example to fetch links from a website : http://www.merchantos.com/makebeta/php/scraping-links-with-php/ $xpath =
From this example http://www.senchafiddle.com/#dPZn0 This displays a first panel, then a second one... using
I'm using this: http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_toggle the thing here is that i change the button to
Can you explain how mod_rewrite works using this as an example: http://www.domain.com/page.php?q=keyword1,keyword2,keywordn&page=x&param=i => http://www.domain.com/page/keyword1,keyword2,keywordn?page=x&param=i
Using this code var sw = window.screen.width; $.post(http://www.example.com/track.php, {result: sw }, html); and $_SERVER['result'];
I'm using this plugin: http://www.jeremymartin.name/projects.php?project=kwicks And my code follows this example: http://www.jeremymartin.name/examples/kwicks.php?example=7 I'm using
from this site there is header compress.h http://www.fredosaurus.com/notes-cpp/examples/compress/compress.html i am using visual c++ 2010
I have a url in this form http://www.example.com/data/45 . How do I get the
I tried using this example: http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/modalpopup/modalpopup.aspx <ajaxToolkit:ModalPopupExtender ID=MPE runat=server TargetControlID=LinkButton1 </ajaxToolkit:ModalPopupExtender> And try using
I'm having an issue using the % wildcard with a MySQL query. http://www.w3schools.com/sql/sql_like.asp Having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.