How to process server side parameter sent from jquery datatables using Flask?

前端 未结 2 726
轻奢々
轻奢々 2021-02-15 11:49

I am having some issues in processing the parameters sent by jquery datatables 1.10 when server side processing is enabled. I initialized the datatable in the javascript side li

相关标签:
2条回答
  • 2021-02-15 12:32

    Get DataTable to send json

    ajax: {
        url: "/api/data_table",
        type: "POST",
        data: function ( args ) {
          return { "args": JSON.stringify( args ) };
        }
    },
    

    In flask, parse the json

    args = json.loads(request.values.get("args"))
    columns = args.get("columns")
    
    0 讨论(0)
  • 2021-02-15 12:47

    You can use this little nifty package that I found https://github.com/bernii/querystring-parser

    from querystring_parser import parser
    args = parser.parse(request.query_string)
    print args['columns']
    
    0 讨论(0)
提交回复
热议问题