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 8512385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:15:57+00:00 2026-06-11T04:15:57+00:00

I am using the awesome datatables jquery plugin, but I am having some issues

  • 0

I am using the awesome datatables jquery plugin, but I am having some issues with the rendering of the table.

I have the following code:

$(document).ready(function() {
var jsonEmp="";
$.getJSON("../lib/violation_select_emp.php", function(json) {
    jsonEmp = json;
}); 

var oTable;
oTable = $('#uview').dataTable({
    "bStateSave":true,
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "../lib/server_processing_emp_list.php",
    "sPaginationType": "four_button",
    "aaSorting": [[ 0, "asc" ]],
    "aoColumns": [
    {
        "fnRender": function ( oObj ) {
         var empID=oObj.aData[4];
         var empName=oObj.aData[5];
         return "<a href='viewEmployer.php?empID="+empID+"'>"+empName+"</a>";
    }
    },
    {
        "fnRender": function ( oObj ) {
            var numAlerts=jsonEmp.length;
            var i=0;
            var alerts=0;
            while(i<numAlerts){
            if(jsonEmp[i]==oObj.aData[3]){
                alerts++;
            }
            i++;
    }
    return alerts;
    }
});
});

When I load the page, nothing shows up in the column with the fnrender, but when I hit the next paginition button, and then hit the previous pagination button, I see the information that I am looking to see.

My theory is that the table needs to be refreshed, but when I do that it results in the same thing happening.

Not sure what to do, hopefully someone can help me out.

  • 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-11T04:15:59+00:00Added an answer on June 11, 2026 at 4:15 am

    You have a callback function for $.getJSON. In the callback function you assign a value to your jsonEmp variable which was initialized with “”. Your code doesn’t wait for a response from the website where you are sending a request, your Javascript code below $.getJSON won’t wait for the page to respond, leading to the bug of using jsonEmp before you assigned a real-life value to it.

    Suggestion:

    $(document).ready(function() {
    var jsonEmp="";
    var oTable;
    $.getJSON("../lib/violation_select_emp.php", function(json) {
        jsonEmp = json;
    oTable = $('#uview').dataTable({
        "bStateSave":true,
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "../lib/server_processing_emp_list.php",
        "sPaginationType": "four_button",
        "aaSorting": [[ 0, "asc" ]],
        "aoColumns": [
        {
            "fnRender": function ( oObj ) {
             var empID=oObj.aData[4];
             var empName=oObj.aData[5];
             return "<a href='viewEmployer.php?empID="+empID+"'>"+empName+"</a>";
        }
        },
        {
            "fnRender": function ( oObj ) {
                var numAlerts=jsonEmp.length;
                var i=0;
                var alerts=0;
                while(i<numAlerts){
                if(jsonEmp[i]==oObj.aData[3]){
                    alerts++;
                }
                i++;
        }
        return alerts;
        }
    });
    }); 
    
    });
    

    As you can see, I’ve put the initialization of your object into the callback function, I still believe your problem comes from initialization, but I didn’t test the code. Let me know of the results of my suggestion.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the dataTables jQuery plugin (which is totally awesome), but I'm having trouble
I'm using this plugin http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/ and it works awesome!! but I'd like to make
I have very interested in using MongoDB it seems awesome. But I'm from a
I'm using Ariel Flesler's awesome scrollto plugin . But I want to determine when
I'm using an awesome plugin to validate my form on the front-end: http://docs.jquery.com/Plugins/Validation .
I'm currently using the awesome attachment-fu plugin for a Rails app, but as a
So I'm using the awesome trollop gem to do option parsing, but I'm having
I've been using the DataTables jQuery plugin with the filter plug in, and it
I have a web form that is using this awesome plugin and I'm trying
I'm using CodeIgniter (because it's awesome) and I have something like: <?php echo anchor(/,

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.