ajax call to php with data

ajax call to php with data

esdras2424esdras2424 Posts: 2Questions: 1Answers: 0
edited July 2020 in Free community support

i want to make a ajax call with data within so php functions can return me thru echo a json file, something like this

$('#example').DataTable( {
        "ajax":{
          "method": "POST",
          "url": "../php/todo.php",
        },
        "data": {
          lastUser: lastUser,
          tipoSorteo: tipoSorteo,
          horarioSorteo: horarioSorteo,
          fecha1: fecha1,
          fecha2: fecha2,
          ejecutar: "ejecutar"
        },
        "columns": [
            { "data": "tiquete" },
            { "data": "numero" },
            { "data": "monto" },
            { "data": "fecha" },
            { "data": "hora" },
            { "data": "tipo" }
        ]
    } );

Edited to add syntax highlighting

Answers

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin

    Use ajax.data to send data to the server.

    Note that the top level data which you are using there should be an array, not an object (it could be an array which contains objects), but is it just is the wrong place? Is that want to what you want to send to the server? Move it into the ajax option.

    Allan

  • esdras2424esdras2424 Posts: 2Questions: 1Answers: 0

    i´ll try

This discussion has been closed.