cannot get the dynamic input value

cannot get the dynamic input value

wwquestionwwquestion Posts: 2Questions: 1Answers: 0
edited November 2022 in Free community support

Javascript

var table = $('#itemTable').DataTable({
      "lengthMenu": [ [5], [5], ],
      "processing": true,
      "serverSide": true,
      "serverMethod": 'post',
      "ajax": {
          'url':'/jsitemlist/' ,
          'type': 'POST',
          'data':{p_mcode : $("#m_item_code").val(), },
      },


    $("#btnsearch").on('click', function(event){
      console.log('btn search---'+$("#m_item_code").val());    // can show the value
      table.draw();
    });

but at the jsitemlist ( flask module ),

    def jsitemlist():
        print( request.form['p_mcode'] )     # no value display.

Any idea what wrong on this code ? thanks a lot.

Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736
    Answer ✓

    Likely the problem is you need to use ajax.data as a function for dynamic values. Otherwise you will continually send the value that Datatables initialized with. See this example.

    Kevin

  • wwquestionwwquestion Posts: 2Questions: 1Answers: 0

    problem solved, thank you a lot.

Sign In or Register to comment.