0

i tried using ajax/datable/codeigniter and i want to send my data in post like array data for example (search['value'] = searched_key).

 function fetch_vtourdata( is_range_search, minPrice = '', maxPrice = '', minSurface = '', maxSurface = '', minNbRoom = '', maxNbRoom = '', searched_key = '')
 {
 var dataTable = $('#data_tableVtoursList').DataTable({
 "processing": true,
 "serverSide": true,
 "order": [],
 "ajax":{
 url: "../../website/userVtourTable",
 type: "POST",
 data: { 'user_id': user_id,
 // 1 = name of POST, 2 = values
 is_range_search:is_range_search,
 minPrice:minPrice,
 maxPrice:maxPrice,
 minSurface:minSurface,
 maxSurface:maxSurface,
 minNbRoom:minNbRoom,
 maxNbRoom:maxNbRoom,
 search[{
 'value':searched_key
 }] 
 }
 },
 "columnDefs" : [
 {
 "target": [0, 3, 4],
 "orderable": false,
 }
 ]
 });
 $('#search').keyup(function(){
 dataTable.search($(this).val()).draw();
 });
 }

enter image description here

asked Aug 18, 2017 at 15:40
2
  • And what is your question? Commented Aug 18, 2017 at 15:46
  • search[{ 'value':searched_key }] not working Commented Aug 18, 2017 at 15:49

2 Answers 2

1

my result is same than my first post just change :

search [{
 'value' : searched_key
}]

by

searched_key: searched_key

define in your controller method :

if ( isset( $_POST['searched_key'] ) && !empty( $_POST['searched_key'] ) ) {
 $_POST['search']['value'] = $_POST['searched_key']; 
}
answered Aug 30, 2017 at 14:05

Comments

0

Use the data table function and place the datable dunction inside your javascript below your html, seperate the ajax data inside a controller

Could you tell more details about your problem ? like this

 var oTable = $('#example').DataTable({
 "ajax": "<?php echo base_url('dashboard/show_karyawan'); ?>",
 "bDestroy": true,
 "columns": [
 {
 "data": "id",
 render: function (data, type, row, meta) {
 return meta.row + meta.settings._iDisplayStart + 1;
 }
 },
 { "data": "NIP" },
 { "data": "nama" },
 { "data":"jabatan"},
 {
 "data": null, 
 "sDefaultContent": '<a href="" class="editor_view">view</a> / <a href="" class="editor_remove">Delete</a>'
 }
 ]
 }); 

I will suggest you use the newest Datatables, since there some function that wont work with the tutorial of datatables nowadays.

Datables ver. 1.10

answered Aug 24, 2017 at 5:46

2 Comments

my problem is just send data to get $_POST['search']['value'] in my controller method but it's resolved, i just send my data like this :"data": {searched_jey:searched_key} and define in my method $_post['search']['value'] = $_post['searched_key'];
@ITS could you upload the result you have made ? for the future viewers

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.