fnReloadAjax issue

fnReloadAjax issue

rage10940rage10940 Posts: 48Questions: 0Answers: 0
edited April 2013 in Bug reports
Hello Allan, I came across a problem with fnReloadAjax.

The problem :

>> When two different computers are on the same page using fnReloadAjax on the same table when some one alters the data for example say when column = 3 instead of 2 the data in the first client that initiated the change is gone (which should work) but in the second client / computer the old data where is still there.

When I say still there, I mean that since the value of column is not 2 any more (it is 3) the data should not be showing in that table, but the second client still has the data shown on the table.

Possible issue (that I can think of?) :

One minute the fnReloadAjax is in fact retrieving the JSON data, but when the JSON data is not present any more (when the column value now equals 3 rather then 2) the data on the second client still shows up on that table (when it shouldn’t').

When I go home tonight I will turn my server on and hopefully you can have a look at it. I will also upload a video and put it on this thread to show you in more detail the issue.

For the mean time my code is :

[code]
function ajaxcall() {
$this->load->model('queue_model');

$data['waiting'] = $this->queue_model->waiting();
$data['beingseen'] = $this->queue_model->beingseen();

$this->output->set_header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);
}
[/code]

[code]

$(document).ready(function()
{
var table1 = $('#waiting').dataTable(
{
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"iDisplayLength": 10,
"aLengthMenu": [5, 10],
"sAjaxDataProp": "waiting",
"sAjaxSource": '<?php echo base_url();?>studentqueue_controller/ajaxcall',
"bDeferRender": true,
"bAutoWidth": false,
"aoColumns":
[
{"mdata": "id",
"sWidth": "7%",
"mRender": function(data, full)
{
var div = '';
var url = '' + '' + '' + '' + data + '';
}
},
{"mdata": "first"},
{"mdata": "last"},
{"mdata": "SECOND",
"sWidth": "1%"
},
{"mdata": "reason"},
{"mdata": "studentcomments"},
{"mdata": "aidyear",
"sWidth": "1%"
},
{"mdata": "counselorcomments"}
]
});
setInterval(function() {
table1.fnReloadAjax(null, null, true);
}, 1000);
});


$(document).ready(function()
{
var table2 = $('#beingseen').dataTable(
{
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"iDisplayLength": 10,
"aLengthMenu": [5, 10],
"sAjaxDataProp": "beingseen",
"sAjaxSource": '<?php echo base_url();?>studentqueue_controller/ajaxcall',
"bDeferRender": true,
"bAutoWidth": false,
"aoColumns":
[
{"mdata": "id",
"sWidth": "1%",
"mRender": function(data, full)
{
var div = '';
var url = '' + '' + '

Replies

  • rage10940rage10940 Posts: 48Questions: 0Answers: 0
    Hey Allan here is the video :

    http://www.youtube.com/watch?v=Dod5Rznj6BQ

    I will also keep my server up tonight, and the login is the same as before, if my IP changed I will send you notification!

    Thanks Allan,

    Hopefully this is a small issue.
  • allanallan Posts: 56,819Questions: 1Answers: 9,029 Site admin
    Students waiting is being reloaded very 1 second yes? What does the data for the Ajax request when it in the 'wrong' state look like?

    If you have a look at the fnReloadAjax plug-in, you will see that it calls fnClearTable followed by fnAddData - so my guess is that the Ajax request is getting incorrect data back (i.e. it is reporting a row when it shouldn't be).

    Allan
  • rage10940rage10940 Posts: 48Questions: 0Answers: 0
    edited April 2013
    Yes the students waiting is being reloaded on a second by second basis. I am in the chrome developer tools and it is showing two errors called :

    Uncaught TypeError: Cannot read property 'length' of null

    and

    Uncaught TypeError: Cannot read property 'length' of null

    http://www.freeimagehosting.net/wh71n
  • allanallan Posts: 56,819Questions: 1Answers: 9,029 Site admin
    I'm not sure what is causing that I'm afraid. I'd need a test case to be able to debug it.

    Allan
  • rage10940rage10940 Posts: 48Questions: 0Answers: 0
    I sent you an email with my server IP and your credentials. Is that what yo mean by a test case?
  • rage10940rage10940 Posts: 48Questions: 0Answers: 0
    To test it like I explained in the email, you would sign a student in on computer and then on another computer you would see the ajax refresh the table. Then on the same computer you signed in a student, accept the student (with the green check box) and then notice on another computer how the table "freezes"
  • rage10940rage10940 Posts: 48Questions: 0Answers: 0
    Any word Allan?
  • allanallan Posts: 56,819Questions: 1Answers: 9,029 Site admin
    I'm getting no response from the IP address you previously sent me.

    Allan
  • rage10940rage10940 Posts: 48Questions: 0Answers: 0
    Sent you a message on DataTables conversation thing (PM?)
  • rage10940rage10940 Posts: 48Questions: 0Answers: 0
    No bug here, (unless Allan can fix my brain? oO....)

    I was sending a NULL value to the datatables so it was always looking for data saying Loading Data.... when there was none.

    So in my query :

    [code]

    function waiting() {
    $sql = "SELECT DISTINCT
    session.session_id as id,
    session.anum,
    student.first,
    student.last,
    SEC_TO_TIME(TIMESTAMPDIFF(SECOND, signintime, NOW())) as SECOND,
    reasons.reason,
    session.studentcomments,
    session.aidyear,
    support.counselorcomments
    FROM session
    INNER JOIN student
    ON student.anum = session.anum
    LEFT JOIN support
    ON session.session_id = support.session_id
    INNER JOIN reasons
    ON reasons.reason_id = session.why
    LEFT JOIN support support2
    ON support.session_id = support2.session_id
    AND support.starttime < support2.starttime
    WHERE session.status IN (0,2) AND support2.session_id IS NULL
    ORDER BY id asc;";
    $q = $this->db->conn_id->prepare($sql);
    $q->execute();

    if ($q) {
    if ($q->rowCount() > 0) {
    return $q->fetchall();
    } else {
    return $q = array(); // All I had to add was an empty array
    }
    }
    }

    [/code]

    Literally two lines of code fixed this... One line for this query and another line for the other query. Thanks Allan!
This discussion has been closed.