Does not send post parameter in ajax.data

Does not send post parameter in ajax.data

Wilmer30Wilmer30 Posts: 33Questions: 10Answers: 1

The cod is as follows:

        var table = $('#datatable').DataTable({
        // "processing": true,
        "serverSide": true,
          "ajax": '<?php echo base_url() ?>documentos/getDocExpAjax',
          "type": 'POST',
          "data": {
            "id": $("#expedientes").val()
          },
        });

The id parameter does not send to the server.

It may be something simple but I have not solved it, thanks for your help

This question has an accepted answers - jump to answer

Answers

  • Tester2017Tester2017 Posts: 145Questions: 23Answers: 17

    First you can delete this part <?php echo base_url() ?>. The script is client side working and does not have access to your php environment on the server.

  • Wilmer30Wilmer30 Posts: 33Questions: 10Answers: 1

    Thanks for your prompt reply, but base_url() is indistinct, because it is actually converted to:
    controller/documents/getDocExpAjax

  • kthorngrenkthorngren Posts: 21,174Questions: 26Answers: 4,923
    Answer ✓

    I think the problem is you haven't put your ajax parameters inside {}. The only parameter being used is the URL. This example will help:
    https://datatables.net/examples/server_side/post.html

    Need to put your 'data parameter inside the {} also.

    Kevin

  • Wilmer30Wilmer30 Posts: 33Questions: 10Answers: 1

    Thanks kthorngren I have to be careful in the syntax.

This discussion has been closed.