Pass Cell Values From a Single Column to a POST

Pass Cell Values From a Single Column to a POST

j0hnj0hn Posts: 2Questions: 0Answers: 0
edited April 2012 in General
What's the best way to send the values from Column0 to a php POST request (POST /file.php?param=celldata) and inject the results into Column4? Right now, records are displayed into a table and datatables is handling the pagination and sorting (which is awesome). I'm a total novice when it comes to jquery/js/datatables, but with some assistance, I've managed to put together the following, which works perfectly:

[code]

$(document).ready(function() {
$('#table_id').dataTable( { "sPaginationType": "full_numbers", "iDisplayLength": 25, "bStateSave": false, "aaSorting": [[ 0, "asc" ]] } );

[/code]

How can I expand on this to pass the cell values in Column0 to php and inject the json result in Column4? The PHP handler was easy enough and appears to work fine:

[code]
$ curl -k -F "param=celldata" https://server/file.php
{"result":"newcelldata\n"}
$
[/code]

Managed to get this far as this also works. The alert function produces what should go into Column4.

[code]
$.post("https://server/file.php", { param: "examplecelldata" },
function(data) {
alert(data.result);
}, "json");
[/code]

Someone mentioned using the fnDrawCallback function. The idea is to pass the cell data from each row in Column0 to the php handler each time the table is drawn for the currently displayed data (ie, scrolling through the pages) as opposed to performing thousands of queries all at once.

Thanks,

J

Replies

  • j0hnj0hn Posts: 2Questions: 0Answers: 0
    Made a bit of progress... This manages to pass all the rows in Column0 to PHP, but all the rows are combined into a single value...

    So instead of passing:
    ?param=celldata0
    ?param=celldata1
    ?param=celldata2

    etc, it's passing...

    ?param=celldata0celldata1celldata2...

    [code]
    $.post('/file.php', { param: $(".Column0row").text() }, function(data) { alert(data.result) }, "json");
    [/code]
This discussion has been closed.