How can i import json in datatable from console..in python flask

How can i import json in datatable from console..in python flask

karan_1994karan_1994 Posts: 6Questions: 1Answers: 0
edited April 2018 in Free community support

Please help me out...as mostly it depends on jquery but any hints would really work.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945
    Answer ✓

    How can i import json in datatable from console..in python flask

    Sorry, I don't understand your question. Can you provide a bit more detail of what you want to do? I'm a bit confused about the "console" part of the question.

    Kevin

  • karan_1994karan_1994 Posts: 6Questions: 1Answers: 0

    hi .. I have a json returned and i am printing it on a console.
    using javascript..how do I print it in data tables.

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945

    You can add it to Datatables using the rows.add() API. Then use draw() to redraw the updated Datatable.

    Kevin

  • karan_1994karan_1994 Posts: 6Questions: 1Answers: 0

    code for my html and javascript.

  • karan_1994karan_1994 Posts: 6Questions: 1Answers: 0

    code for javascript..
    this is the file where i need to use ajax in order to access the url and display data in tables..
    So how do i call the url

  • karan_1994karan_1994 Posts: 6Questions: 1Answers: 0

    $(document).ready(function() {
    $("#submit_btn").click(function(e)
    {
    e.preventDefault();
    $.post( "/output", $( "#main_form" ).serialize(),function(dataSet){
    console.log(dataSet.manufacturerPartNumberSearchReturn);
    //$("#info_table").html(JSON.stringify(data));
    //alert(dataSet.manufacturerPartNumberSearchReturn.products[0].brandName);
    var dataObject = dataSet.manufacturerPartNumberSearchReturn.products; // variable in which api data is.

                $("#example").DataTable(
                {
                  //ajax code will come here.
    
    
                });
    
            });
    });
    

    });

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945
    edited April 2018

    The ajax is used within the Datatables config. There are some examples in the doc page. Also here is an example:
    https://datatables.net/examples/data_sources/ajax.html

    More examples here:
    https://datatables.net/examples/ajax/index.html

    Looks like you want to use the POST option as shown in the docs.

    The Data doc page explains the supported data formats.

    Kevin

  • karan_1994karan_1994 Posts: 6Questions: 1Answers: 0

    Thank you kevin.. You really rock..
    Sorry for late reply.

    I am trying on it

This discussion has been closed.