gongpex Posted November 17, 2016 Share Posted November 17, 2016 (edited) Hello everyone I had tried to post data using jquery data table but it didn't work, here is my code: function table(){ $('#page').DataTable( { "pageLength": 5, "bAutoWidth": true, "processing": true, "serverSide": true, "destroy": true, "columnDefs": [ {"bSortable": false, "aTargets": [ 1, 2, 3, 4]}, { targets: 0 }, { targets: 1 }, { className:'text-center',targets: 2 }, { className:'text-center', targets: 3 }, { className:'text-center', render:function(data,type,row){ return '<a style="cursor:pointer" class="btn btn-xs btn-info my_popup_open" rowid="'+row[6]+'">Edit Data</a>'; },targets: 4 }, ], "ajax" : { "url" : "<?php echo base_url('index.php/loc/data');?>", "type" : "POST", "data": $("#location").val() } }); } and this my php code : function data(){ $location = $this->input->post("id_location"); $start = $_GET["start"]; $rowPerPage = $_GET["length"]; $orderbyIndex = $_GET["order"][0]["column"]; $orderby = $_GET["order"][0]["dir"]; $search = $_GET["search"]["value"]; $draw = $_GET["draw"]; $query = $this->db->query("select * from location where id_loc = '$location'"); // another code on bottom } I want data from Jquery data tables ($("#location").val()) can be sent to my php code Q : what I must do? please help me Thanks Edited November 17, 2016 by gong Link to comment Share on other sites More sharing options...
thescientist Posted November 17, 2016 Share Posted November 17, 2016 are you checking for console errors? checking that data is what you expect it to be? checking the POST request that the browser is sending to verify what's actually getting sent across the wire? Does DataTables have an API you can use to get the data instead (that would seem more practical to me). In general, it's not clear from your post what "doesn't work" means since there's not much detail here to know what debugging you've done. Link to comment Share on other sites More sharing options...
dsonesuk Posted November 17, 2016 Share Posted November 17, 2016 Usually the url would point to php file, 'data': would have index key name and value, your php file is looking for 'id_location' so data would be data: { id_location: $("#location").val() } Link to comment Share on other sites More sharing options...
gongpex Posted November 18, 2016 Author Share Posted November 18, 2016 hmm ok, thanks for answer before, my expectation actually : to make select option that I've made, work when it changed. Here is my screen shot : If I used code on above the result is : "undefined property : start" and etc please help me Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now