Post via POST in Jquery

0

I'm working on an implementation of Datatables, but there was a need to send the id to do the filters:

		$(document).ready(function() {
			var dataTable = $('#employee-grid').DataTable( {
                responsive: false,
				"order": [[ 1, "asc" ]],
				"aoColumns": [
					null,
					null,
					null,					
					null
				],				
				//"scrollY": 400,
				"scrollX": true,
				"iDisplayLength": 100,
				"processing": true,
				"serverSide": true,
				"ajax":{
					url :"../php/admin_gerente_cidade.php",
					type: "post",
					error: function(){
						$(".employee-grid-error").html("");
						$("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">Nenhum resultado encontrado</th></tr></tbody>');
						$("#employee-grid_processing").css("display","none");
					}
				}
			} );
		} );

If I put

url :"../php/admin_gerente_cidade.php?id=<?php $id; ?>"

It does not work.

Would it be possible to pass an id via POST?

    
asked by anonymous 17.07.2017 / 22:50

1 answer

2

Just enter the property data , follow below as it would in your case, replace seu_id with the value you need.

$(document).ready(function() {
            var dataTable = $('#employee-grid').DataTable( {
                responsive: false,
                "order": [[ 1, "asc" ]],
                "aoColumns": [
                    null,
                    null,
                    null,                   
                    null
                ],              
                //"scrollY": 400,
                "scrollX": true,
                "iDisplayLength": 100,
                "processing": true,
                "serverSide": true,
                "ajax":{
                    url :"../php/admin_gerente_cidade.php",
                    type: "post",
                    data: {id: seu_id},
                    error: function(){
                        $(".employee-grid-error").html("");
                        $("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">Nenhum resultado encontrado</th></tr></tbody>');
                        $("#employee-grid_processing").css("display","none");
                    }
                }
            } );
        } );
    
17.07.2017 / 22:56