Не удалось ввести данные, переданные AJAX в таблицу

#php #jquery #ajax #codeigniter #datatable

Вопрос:

В настоящее время у меня есть таблица, в которой я пытаюсь показать все свои данные, полученные из моей модели. Ниже приведен мой код:

Класс контроллера(Contacts.php):

 public function lists($type='')  {  $this-gt;load-gt;library('pagination');  $main['page_title']=$this-gt;config-gt;item('site_name').' - Contacts';  $main['records']=$this-gt;contacts_model-gt;get_records();    $main['jsArray'] = array('public/assets/plugins/datatables/jquery.dataTables.min.js',  'public/assets/plugins/datatables/dataTables.bootstrap.js',  'public/assets/plugins/datatables/dataTables.buttons.min.js',  ,'public/assets/js/jQuery.dtplugin.js',  'public/assets/js/datatable.contacts.js');   $main['cssArray'] = array('public/assets/plugins/datatables/jquery.dataTables.min.css', 'public/assets/plugins/datatables/buttons.bootstrap.min.css');  $main['page'] = 'crm/contacts/index';  $this-gt;load-gt;view('crm/index',$main);  }    public function listsdt($type='1'){   if($type !='') {  $cond['contact_type'] =$type;  }  $this -gt; load -gt; library('Datatable', array('model' =gt; 'contactsdatatable', 'rowIdCol' =gt; 'c.id','conds'=gt;$cond,'order'=gt;'added_date desc'));  $jsonArray = $this -gt; datatable -gt; datatableJson(array( 'added_date' =gt; 'date' ));  $this -gt; output -gt; set_header("Pragma: no-cache");  $this -gt; output -gt; set_header("Cache-Control: no-store, no-cache");  $this -gt; output -gt; set_content_type('application/json') -gt; set_output(json_encode($jsonArray));  }  

Классы моделей:

Contactsdatatable.php:

 lt;?php  class Contactsdatatable extends CI_Model implements DatatableModel{  function __construct()  {  parent::__construct();    }  public function appendToSelectStr() {  return array( 'refid' =gt; 'concat(c.refno, '|',c.id)',  'fnid' =gt; 'concat(c.firstname, ' ',c.lastname, '|',c.id)',   'contact_name' =gt; 'concat(c.firstname, ' ',c.lastname)',  'addedby' =gt; 'concat_ws("",users.display_name,import_source)',  'agent_name'=gt;'cu.display_name',  'contact_source'=gt;'source.title',  'contact_type' =gt; 'types.title' ,  'added_by' =gt; 'users.display_name'  );  }  public function appendToGroupBy() {  return "c.id";  }  public function fromTableStr() {  return 'crm_contacts as c';  }  public function joinArray(){  return array(   'crm_clients_users as cu|left' =gt; 'cu.id = c.agents_id',  'crm_contacts_details as detail|left' =gt; 'detail.contacts_id = c.id and detail.contacttype = "personal"',  'crm_sources as source|left' =gt; 'source.id = c.contact_source and source.language = "'.$this-gt;session-gt;userdata('client_language').'"',  'crm_contact_types as types|left' =gt; 'types.id = c.contact_type and types.language = "'.$this-gt;session-gt;userdata('client_language').'"',  'crm_clients_users as users|left' =gt; 'c.added_by = users.id and users.clients_id = "'.$this-gt;session-gt;userdata('clientsessid').'"'  );  }  public function whereClauseArray(){  return array('c.delete_status'=gt;'N');  }  } ?gt;  

Contacts_model.php:

 function get_records(){  $this-gt;db-gt;select("*");  $this-gt;db-gt;from("crm_contacts as con");  $this-gt;db-gt;where("con.status='Y'");  $query = $this-gt;db-gt;get();  return $query-gt;result();  }  

View class:

 lt;table id="datatable" class="table table-striped table-bordered dtcontacts"gt; lt;/tablegt; ... var ajax_base_url = 'lt;?php echo site_url('contacts/listsdt/'); ?gt;';  

datatable.contacts.js:

 $(function() { datatable_contacts(); $( '#fkeyword' ).on( 'keyup change', function () { $('#datatable').DataTable() .column().search(this.value, true) .draw(); });   // for select box $('.search-input-select').on( 'change', function () { searchcoloms($(this),$(this).val());}); }); function searchcoloms(obj,value){  var i =obj.data('column');  var v =value;  var table =$('.dtcontacts').dataTable();  table.api().columns(i).search(v).draw(); } function datatable_contacts(){  //wait till the page is fully loaded before loading table  //dataTableSearch() is optional. It is a jQuery plugin that looks for input fields in the thead to bind to the table searching  var dataTableLists = $(".dtcontacts").dataTable({  searching: true, paging: true, "lengthChange": false, "bInfo": true,  columnDefs: [ {  orderable: false,  className: 'select-checkbox',  targets: [9,10]  } ],  select: {  style: 'os',  selector: 'td:first-child'  },  order: [[7, 'desc' ]],   oLanguage: { sProcessing:false },  lengthMenu: [[ 25, 50, 100], [25, 50,100]],/*"dom": 'lt;"top"fgt;rtlt;"bottom"ilpgt;',*/  pagingType: "full_numbers",  processing: true,  serverSide: true,  bFilter:true,  ajax: {  "url": ajax_base_url,  "type": "POST"  },  columns: [    { data: "$.refid",  render: function ( data, type, row ) {var d = data.split("|");   if ( type === 'display' ) {  return 'lt;a class="text-info" href="' site_url_view d[1] '"gt;' d[0] 'lt;/agt;' ;   }  return data;  }  },  {data: "$.fnid",  render: function ( data, type, row ) {var d = data.split("|");   if ( type === 'display' ) {  return 'lt;a class="text-info" href="' site_url_view d[1] '"gt;' d[0] 'lt;/agt;' ;   }  return data;  }  },  { data: "detail.mobile" ,  render: function ( data, type, row ) {  if ( type === 'display' amp;amp; data) {  return 'lt;a class="text-info" href="tel:' data '"gt;' data 'lt;/agt;' ;   }  return data;  }},   { data: "detail.email",  render: function ( data, type, row ) {  if ( type === 'display' amp;amp; data) {  return 'lt;a class="text-info" href="mailto:' data '"gt;' data 'lt;/agt;' ;   }  return data;  } },   { data: "$.contact_source" },  { data: "$.contact_type" },  { data: "$.agent_name",  render: function ( data, type, row ) {  if ( type === 'display') {  return 'lt;span class="' (data?'':'text-warning') '"gt;' (data?data:'Unassigned') 'lt;/spangt;' ;   }  return data;  }},   { data: "added_date" },   { data: "$.addedby" }  return data;  }, className: "text-center"}  ]  }).dataTableSearch(1); }  

При этом я все еще не могу отобразить свои данные в таблице. Я также не получаю ответ AJAX. Я должен получить listsdt/ на вкладке «Сеть», но я не получаю никакого ответа AJAX