How can i save the value of search field?
How can i save the value of search field?
Jordano95
Posts: 3Questions: 2Answers: 0
hello!
I would like to send with POST the value of the field "search" of datatable to use it to initialize another page , it is possible ?
i try in thi way
$(document).ready(function() {
var table = $('#elencoprodotti').DataTable( {
"language": {
"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Italian.json",
"decimal": ",",
"thousands": "."
},
"ajax": {
"url": modulo+"_get_elenco.php?tabella=",
"dataSrc": ""
},
"columns": [
{ "data": "IMG" },
{ "data": "CODICE" },
{ "data": "CODICE_OBSOLETO" },
{ "data": "DESCRIZIONE" },
{ "data": "CATEGORIA" },
{ "data": "FORNITORE" },
{ "data": "UM_BREVE" },
{ "data": "QTA_NEW" },
{ "data": "SCORTA_MINIMA" }
],
"columnDefs": [
{
"targets": [0],
"searchable": false, // disabilita la ricereca per il campo con indice 0
"orderable": false // disabilita l'ordinamento4
},
$('#elencoprodotti').on('change', function() {
var value = $('.dataTables_filter input').val();
//alert(value); // <-- the value
$.ajax({
type:"POST",
method:"POST",
url: "ciao.php",
data:{ 'value': value},
success: function(){
alert(value);
}
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @Jordano95,
That's close - take a look at this page here. For you, this should do the trick:
Cheers,
Colin
thanks @colin for the answer but how can i include it in my code?
sorry but i'm new with javascript and ajax
You currently have
so just replace that with
Then your server script can access the
mySearch
value.Cheers,
Colin