Ajax data in headers but not $_POST

Ajax data in headers but not $_POST

SpringsTeaSpringsTea Posts: 11Questions: 1Answers: 0
edited June 2014 in Free community support

I'm a student intern right now, and I've been stuck on this issue all week.
I can't provide a link because it's behind a firewall for now, so I'll do my best to provide information.

I'm using ajax to pull from a db with the following datatables code:

$(document).ready(function(){
        $('#myTable').dataTable({
        "processing": true,
        "serverSide": true,
        "ajax": {"url": "ajax.php",
                 "type": "POST"},
        //"sServerMethod":"POST",
        'iDisplayLength': 10
        
        });
    });

The problem I'm having is the data that Datatables is automatically supposed to say, specifically the start and length.
When it posts to my server sided script, I can see the data I want in the sent Headers:formdata:

columns[167][orderable]:true
columns[167][search][value]:
columns[167][search][regex]:false
order[0][column]:0
order[0][dir]:asc
start:0
length:10
search[value]:
search[regex]:false

But every example I see grabs the info from $_POST to dynamically query data. My $_POST only contains "draw" and all of the column data. Where are the parameters, like length and start that I can see are being sent, going?

Replies

  • allanallan Posts: 61,451Questions: 1Answers: 10,055 Site admin

    You aren't going to like this, but I would need a test case showing the problem to be able to replicate the issue. I'm not aware of any bugs in DataTables in this area at the moment, and my examples on this site appear to be working correctly, so I would need a way of being able to reproduce the issue to be able to offer any help by debugging it. You might be able to recreate the issue using the test bin?

    Allan

  • SpringsTeaSpringsTea Posts: 11Questions: 1Answers: 0
    edited June 2014

    http://live.datatables.net/ticabos/1/edit?html,js,output

    Ok, I dont know how thats any help when there no place to put the serverside code.

    ( I'm just going to upload my ajax.php https://www.mediafire.com/?h8yboo9oo4w3yrd)

  • allanallan Posts: 61,451Questions: 1Answers: 10,055 Site admin

    If I modify your live example so that it at least executes ( http://live.datatables.net/ticabos/2/edit ), I can see that it is sending out all of the required parameters (below). The server-side would be able to see that:

    draw:1
    columns[0][data]:0
    columns[0][name]:
    columns[0][searchable]:true
    columns[0][orderable]:true
    columns[0][search][value]:
    columns[0][search][regex]:false
    columns[1][data]:1
    columns[1][name]:
    columns[1][searchable]:true
    columns[1][orderable]:true
    columns[1][search][value]:
    columns[1][search][regex]:false
    order[0][column]:0
    order[0][dir]:asc
    start:0
    length:10
    search[value]:
    search[regex]:false
    

    Allan

  • SpringsTeaSpringsTea Posts: 11Questions: 1Answers: 0

    Right, I can see on my end that those are being sent aswell, but the problem I'm having is if the server side calls for $_POST['length'], it will return null.

  • allanallan Posts: 61,451Questions: 1Answers: 10,055 Site admin

    I can only guess that there is a configuration error in the server, or that there is information that I'm not aware of, since the client is sending length as a POST parameter.

    Allan

  • SpringsTeaSpringsTea Posts: 11Questions: 1Answers: 0

    It took a long time for me to get a straight answer our of the people who manage the site.
    The POST max capacity is 128mb, and theres no way I'm exceeding that.
    The server is not configured in any unusual way that should prevent accepting POST data.

    Is there anything else it could be?

  • allanallan Posts: 61,451Questions: 1Answers: 10,055 Site admin

    Not a clue I'm afraid. I've not seen this happening with any other site. I would need a test case showing the problem to be able to debug it. As I noted above, the test case you provided above, if I modified it so it actually ran, it worked as expected.

    Allan

This discussion has been closed.