Welcome Guest, Not a member yet? Register   Sign In
JSON and datatables run well in localhost, in real not.
#1

Hi.

I am created web using json n datatables, in localhost runwell. But after i upload to real server, its database doesnt show content, but error like this : DataTables warning: table id=mytable - Ajax error. For more information about this error, please see http://datatables.net/tn/7

Is there any things should i setting in cpanel or else?
Thanks for helping.
Reply
#2

I would check the database versions, could be the live one is a lower version.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

@kelapamuda,

You might want to also check to make sure that your JSON data call matches the dataTable columns.
Reply
#4

Open Chrome inspect tool, then Network tab. Now refresh the page, you should see all your AJAX request under XHR filter.

It'll give you good idea if it return weird response code, anything other than 200, but more importantly, it'll show you raw response data, sometimes you get PHP errors in there that might break Datatable.
Reply
#5

(This post was last modified: 09-18-2018, 08:24 PM by kelapamuda.)

Well because i am beginner, i still confused.
When i try 
http://xxx.com/testing/testing2/index.ph...r_edit_own    it shows web normally, but data table is empty and error
When i try 
http://xxx.com/testing/testing2/index.ph...t_own/json   it is empty  , 404 Page Not Found

Any help how to trace it ?
Reply
#6

@kelapamuda,

Can you show us the code for your view and datatables ajax call and an example of the JSON file?
Reply
#7

(This post was last modified: 09-19-2018, 07:18 PM by kelapamuda.)

Code:
<div class="content-wrapper">
   <section class="content">
       <div class="row">
           <div class="col-xs-12">
               <div class="box box-warning box-solid">
   
                   <div class="box-header">
                       <h3 class="box-title">KELOLA DATA STUDENT</h3>
                   </div>
       
       <div class="box-body">
       <div style="padding-bottom: 10px;"'>
       <?php echo anchor(site_url('z_student/create'), '<i class="fa fa-wpforms" aria-hidden="true"></i> Tambah Data', 'class="btn btn-danger btn-sm"'); ?></div>
       <table class="table table-bordered table-striped" id="mytable">
           <thead>
               <tr>
                   <th width="30px">No</th>
            <th>Name</th>
            <th width="200px">Action</th>
               </tr>
           </thead>
        
       </table>
       </div>
                   </div>
           </div>
           </div>
   </section>
</div>
       <script src="<?php echo base_url('assets/js/jquery-1.11.2.min.js') ?>"></script>
       <script src="<?php echo base_url('assets/datatables/jquery.dataTables.js') ?>"></script>
       <script src="<?php echo base_url('assets/datatables/dataTables.bootstrap.js') ?>"></script>
       <script type="text/javascript">
           $(document).ready(function() {
               $.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings)
               {
                   return {
                       "iStart": oSettings._iDisplayStart,
                       "iEnd": oSettings.fnDisplayEnd(),
                       "iLength": oSettings._iDisplayLength,
                       "iTotal": oSettings.fnRecordsTotal(),
                       "iFilteredTotal": oSettings.fnRecordsDisplay(),
                       "iPage": Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
                       "iTotalPages": Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
                   };
               };

               var t = $("#mytable").dataTable({
                   initComplete: function() {
                       var api = this.api();
                       $('#mytable_filter input')
                               .off('.DT')
                               .on('keyup.DT', function(e) {
                                   if (e.keyCode == 13) {
                                       api.search(this.value).draw();
                           }
                       });
                   },
                   oLanguage: {
                       sProcessing: "loading..."
                   },
                   processing: true,
                   serverSide: true,
                   ajax: {"url": "z_student/json", "type": "POST"},
                   columns: [
                       {
                           "data": "id",
                           "orderable": false
                       },{"data": "name"},
                       {
                           "data" : "action",
                           "orderable": false,
                           "className" : "text-center"
                       }
                   ],
                   order: [[0, 'desc']],
                   rowCallback: function(row, data, iDisplayIndex) {
                       var info = this.fnPagingInfo();
                       var page = info.iPage;
                       var length = info.iLength;
                       var index = page * length + (iDisplayIndex + 1);
                       $('td:eq(0)', row).html(index);
                   }
               });
           });
       </script>
 It is the view,,,but i dont know where is the location of  "datatables ajax call and an example of the JSON file" as you said. Sorry because i am a beginner. ( And that website is created using ci generator that name garuda crud generator, thats why i dont understand the coding fully. Thanks for helping.

Reply




Theme © iAndrew 2016 - Forum software by © MyBB