javascript - Datatables Dynamic AJAX POST - Stack Overflow

Using Datatables with AJAXPOST, I initialize like this, where experiment_list is a list, and $("

Using Datatables with AJAX / POST, I initialize like this, where experiment_list is a list, and $("#type") is a selector menu.

var my_table = $('#my_table').DataTable( {
        "ajax": {"url": "/experiment_data/", "type":"POST", "data": {"experiments": experiment_list, "type": $("#type_selector").val() } },
"dom": '<"top">rt<"bottom"fp><"clear">', 
   } );

The problem I am having is that "type" is at initialization to the selector menu value, and changing the value after that and reloading the data, does not change the value in the "ajax" method.

$("#type_selector").change(function () {
    console.log($("#type_selector").val()); 
    position_table.ajax.reload()
    }); 

The API Documentation only has .url() for a dynamic method, which would mean either using GET (which is not very good for object type data) or rewriting views for each selector 'type' (and changing the url on select).

Is there a way to update the Data load of the Post request Dynamically?

Using Datatables with AJAX / POST, I initialize like this, where experiment_list is a list, and $("#type") is a selector menu.

var my_table = $('#my_table').DataTable( {
        "ajax": {"url": "/experiment_data/", "type":"POST", "data": {"experiments": experiment_list, "type": $("#type_selector").val() } },
"dom": '<"top">rt<"bottom"fp><"clear">', 
   } );

The problem I am having is that "type" is at initialization to the selector menu value, and changing the value after that and reloading the data, does not change the value in the "ajax" method.

$("#type_selector").change(function () {
    console.log($("#type_selector").val()); 
    position_table.ajax.reload()
    }); 

The API Documentation only has .url() for a dynamic method, which would mean either using GET (which is not very good for object type data) or rewriting views for each selector 'type' (and changing the url on select).

Is there a way to update the Data load of the Post request Dynamically?

Share Improve this question edited Jun 20, 2014 at 7:57 user3467349 asked Jun 20, 2014 at 7:32 user3467349user3467349 3,1915 gold badges40 silver badges64 bronze badges 2
  • which v. of datatables ? – Kalzem Commented Jun 20, 2014 at 7:47
  • Version 1.10 of datatables. – user3467349 Commented Jun 20, 2014 at 7:56
Add a ment  | 

1 Answer 1

Reset to default 4

Did you try with the sample request they provide ?

$('#example').dataTable( {
    "processing": true,
    "serverSide": true,
    "ajax": {
        "url": "/experiment_data/",
        "data": function ( d ) {
            d.experiments = experiment_list;
            d.type = $("#type_selector").val();
        }
    }
});

If it fails, can you provide the log of Firebug please ?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744841547a4596584.html

相关推荐

  • javascript - Datatables Dynamic AJAX POST - Stack Overflow

    Using Datatables with AJAXPOST, I initialize like this, where experiment_list is a list, and $("

    2天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信