search not working
search not working
![lui1969](https://secure.gravatar.com/avatar/78f0fc2bcc6c92356936cf7b22aada75/?default=https%3A%2F%2Fvanillicon.com%2F78f0fc2bcc6c92356936cf7b22aada75_200.png&rating=g&size=120)
no link:
**$(document).ready(function(){
var itemRecords = $('#itemsListing').DataTable({
"lengthChange": false,
"processing":true,
"serverSide":true,
"bFilter": true,
'serverMethod': 'post',
"order":[],
"ajax":{
url:"items_action.php",
type:"POST",
data:{action:'listItems'},
dataType:"json"
},
"columnDefs":[
{
"targets":[0, 5, 6],
"orderable":false,
},
],
"pageLength": 10
});
$('#addItems').click(function(){
$('#itemModal').modal({
backdrop: 'static',
keyboard: false
});
$("#itemModal").on("shown.bs.modal", function () {
$('#itemForm')[0].reset();
$('.modal-title').html("<i class='fa fa-plus'></i> Add Item");
$('#action').val('addItem');
$('#save').val('Save');
});
});
$("#itemsListing").on('click', '.update', function(){
var id = $(this).attr("id");
var action = 'getItemDetails';
$.ajax({
url:'items_action.php',
method:"POST",
data:{id:id, action:action},
dataType:"json",
success:function(respData){
$("#itemModal").on("shown.bs.modal", function () {
$('#itemForm')[0].reset();
respData.data.forEach(function(item){
$('#id').val(item['id']);
$('#itemName').val(item['item_name']);
$('#price').val(item['price']);
$('#itemCategory').val(item['category_id']);
$('#status').val(item['status']);
});
$('.modal-title').html("<i class='fa fa-plus'></i> Edit item");
$('#action').val('updateItem');
$('#save').val('Save');
}).modal({
backdrop: 'static',
keyboard: false
});
}
});
});
$("#itemModal").on('submit','#itemForm', function(event){
event.preventDefault();
$('#save').attr('disabled','disabled');
var formData = $(this).serialize();
$.ajax({
url:"items_action.php",
method:"POST",
data:formData,
success:function(data){
$('#itemForm')[0].reset();
$('#itemModal').modal('hide');
$('#save').attr('disabled', false);
itemRecords.ajax.reload();
}
})
});
$("#itemsListing").on('click', '.delete', function(){
var id = $(this).attr("id");
var action = "deleteItem";
if(confirm("Are you sure you want to delete this record?")) {
$.ajax({
url:"items_action.php",
method:"POST",
data:{id:id, action:action},
success:function(data) {
itemRecords.ajax.reload();
}
})
} else {
return false;
}
});
});**:
No error:
I apologize for my bad English, the problem I find is that the search function does not work I have been trying to understand the cause for days I have carried out many tests by reading the various answers but I can not find anything that works for me.:
This discussion has been closed.
Replies
You are using server side processing (
serverSide: true
) which means your server script is responsible for searching, sort and paging. See the server side protocol docs. There are server side examples you can look at. The server side PHP script used in the examples is here.If you still need help please post a link to your page or a test case replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
thanks for your kind response, in fact the problems I encounter are research and layout. I really need help
To progress this, as Kevin said, please post a link to a test case,
Colin
thanks http://pointscard.moeasy.it/rest/index.php
email: sviluppo@moeasy.it
password: Password-12-12-12
Thanks for your support
i modified the code by adding this lines
after
also I have also entered this code
inside url: "items_action.php",
and I have successfully created the ssp.class.php file inside the root
what I see is a page with "processing ....."
inspecting the code I get this error
TypeError: undefined is not an object (evaluating 'n [m] .style')
It looks like you've got a space between the
$
and your variable name - this would give a syntax error I believe. I'm not that familiar with PHP. Could you give those in the scripts, please, and see if that makes a difference,Colin
thanks for your reply, what script do you want me to insert?
Sorry, I meant "fix those", not "give those". I think
should be
note the space after the
$
. That should be fixed for all the variables.Colin
ok that was a copy and paste problem, it's correct in my code
$primaryKey = 'id';
You've got:
type:"POST",
but are usingSSP :: simple ($ _GET
.All of the information DataTables is sending to the server will be available under
$_POST
, not$_GET
. I'd suggest changing that.Also remove the
serverMethod
option. I don't think it will override yourtype
option in theajax
object, but it is redundant, so remove it.Allan
thanks for your reply i have edited as you described, but i get this error message
DataTables warning: table id=itemsListing - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
this code
('''
''')
Have you followed the troubleshooting steps found in the technote?
http://datatables.net/tn/1
Let us know what you find.
Kevin