开发者

jQuery dataTables with Codeigniter - serverside data

I am using datatables with Codeigniter library (https://github[dot]com/IgnitedDatatables) and I have several problems.

Problem @firebug:

"NetworkError: 500 Internal Server Error - http://www[dot]rodocomp[dot]si/shopmanager/server/datatables?callback=jQuery152008148431712533122_1302880482637"

I assume that error is because of ?callback=jQuery152008148431712533122_1302880482637, right?

Another error @fire开发者_运维技巧bug:

POST http://www[dot]rodocomp[dot]si/shopmanager/server/datata...llback=jQuery152008148431712533122_1302880482637 POST http://www.rodocomp.si/shopmanager/server/datatables?callback=jQuery152008148431712533122_1302880482637 500 Internal Server Error 252ms

Answer:

An Error Was Encountered Unable to load the requested file: ajax.php

What is ajax.php file ??

This is my JavaScript code:

$('#example').dataTable({
      'bProcessing'    : true,
      'bServerSide'    : true,
      'sAjaxSource'    : '<?php echo base_url(); ?>server/datatables',
      'sPaginationType': 'full_numbers',
      'bAutoWidth'     : false,
      'aoColumns'      : [ 
        { 'sName': 'edit', 'bSortable': false },
        { 'sName': 'delete', 'bSortable': false },
        { 'sName': 'products.products_id', 'bVisible': false },
        { 'sName': 'products.products_price' }
      ],
      'fnServerData'   : function(sSource, aoData, fnCallback)
      {
        $.ajax({
          'dataType': 'json',
          'type'    : 'POST',
          'url'     : sSource,
          'data'    : aoData,
          'success' : fnCallback
        }); 
      }, 
});

What am I doing wrong?

Regards, Mario


You're getting that error, because you're not setting the sAjaxSource correctly. First, for the url you've set there, it seems that you've .htaccess removing the need for index.php (if not, this is a error). Maybe you've created a SERVER dir on the root, and that's ok!

Anyway, you can try to place a controller that returns a JSON this way (just to test): "sAjaxSource": "index.php/yourController/yourMethod"

If you're using codeigniter, keep the CI way, on doing things! That's the best way to get this to work.

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜