How to set AJAX response to jquery data table columns?

manohar e

Can anyone tell me how to set the response to jquery data to each table columns.

Here is my javascript code:

$(document).ready (function() {
$.ajax({
    url: 'userController?action=list',
    success : function(response) {
        var jsonObject = $.parseJSON(response); 
        alert(jsonObject.Password);
        alert(jsonObject.UserId);
        $('#usertable').dataTable( {
            data : jsonObject,
            columns: [
                      {'jsonObject' : 'UserId'},
                      {'jsonObject' : 'Password'},
                      {'jsonObject' : 'Level'},               
                      ],
            searching : false
        });
    }
});});

Here the response in String and the response is {"UserId" : "Manohar", "Password" : "1234", "Level" : "lev"}.

Below is the jsp page.

<table id="usertable">
<thead>
    <tr>
        <th>User Id</th>
        <th>Password</th>
        <th>Level</th>
    </tr>
</thead>

I have written the above and neither I am getting error nor the row is added to table. Can you guys help me in this?

manohar e

Here the solution is to change the response. Earlier it was {"userid":"manohar", "password":"1234"}, now I have changed it to [["manohar", "1234"]]. Then in js file

$.ajax({
    url: 'userController?action=list',
    success : function(data, textStatus, jqXHR) {
        var table_data = JSON.parse(data);
        var table = $('#usermaintenancetable').DataTable( {
            data: table_data
}); } });

So here the response is in String format and I have change it to JSON using JSON.parse() then passed this as data to data table.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to re-create jQuery data-table on ajax response?

From Dev

insert ajax response in data table

From Dev

How to set jquery function for all of <a> element in ajax response

From Dev

How can I set data's in twig from Ajax response

From Dev

Dynamic Jquery table constructed using ajax response data on textbox's each keyup event, not showing data of last ajax response (last keyup)

From Dev

How to populate dropdownlist with JSON data as ajax response in jQuery

From Dev

How to access ajax response data as html with javascript or jquery?

From Dev

How to collect collect data from Jquery ajax response to html?

From Dev

How to show json response data in datatable using jQuery ajax request?

From Dev

How to set multiple columns in a data table to values from different columns in the same data table?

From Dev

How to set several columns as the key in data.table package (r)?

From Dev

JQuery $.ajax set cookie and get html response

From Dev

jQuery ajax response bind into MVC Model table

From Dev

jQuery manipulating table rows from ajax response

From Dev

How to pass the array value in to columns attribute of Jquery data table

From Dev

Using jQuery to build table rows from Ajax response (not with static json data)

From Dev

Updating a table of data with ajax/JQuery

From Dev

Displaying data from an Ajax response with Jquery

From Dev

Jquery ajax populate dropdown with json response data

From Dev

send data to php with jquery AJAX and retrieve the response

From Dev

Jquery ajax populate dropdown with json response data

From Dev

jQuery: Post data from ajax response

From Dev

Unable to access AJAX Response Data through jQuery

From Dev

Compare data with ajax response using jquery

From Dev

using jquery ajax how to display searched data displayed into table

From Dev

jQuery Ajax response 200, but cannot access the response data

From Dev

How do I set jquery onclick function to target only specfic table columns or class in an editable table?

From Dev

How to rewrite table using ajax response

From Dev

How to rewrite table using ajax response

Related Related

  1. 1

    How to re-create jQuery data-table on ajax response?

  2. 2

    insert ajax response in data table

  3. 3

    How to set jquery function for all of <a> element in ajax response

  4. 4

    How can I set data's in twig from Ajax response

  5. 5

    Dynamic Jquery table constructed using ajax response data on textbox's each keyup event, not showing data of last ajax response (last keyup)

  6. 6

    How to populate dropdownlist with JSON data as ajax response in jQuery

  7. 7

    How to access ajax response data as html with javascript or jquery?

  8. 8

    How to collect collect data from Jquery ajax response to html?

  9. 9

    How to show json response data in datatable using jQuery ajax request?

  10. 10

    How to set multiple columns in a data table to values from different columns in the same data table?

  11. 11

    How to set several columns as the key in data.table package (r)?

  12. 12

    JQuery $.ajax set cookie and get html response

  13. 13

    jQuery ajax response bind into MVC Model table

  14. 14

    jQuery manipulating table rows from ajax response

  15. 15

    How to pass the array value in to columns attribute of Jquery data table

  16. 16

    Using jQuery to build table rows from Ajax response (not with static json data)

  17. 17

    Updating a table of data with ajax/JQuery

  18. 18

    Displaying data from an Ajax response with Jquery

  19. 19

    Jquery ajax populate dropdown with json response data

  20. 20

    send data to php with jquery AJAX and retrieve the response

  21. 21

    Jquery ajax populate dropdown with json response data

  22. 22

    jQuery: Post data from ajax response

  23. 23

    Unable to access AJAX Response Data through jQuery

  24. 24

    Compare data with ajax response using jquery

  25. 25

    using jquery ajax how to display searched data displayed into table

  26. 26

    jQuery Ajax response 200, but cannot access the response data

  27. 27

    How do I set jquery onclick function to target only specfic table columns or class in an editable table?

  28. 28

    How to rewrite table using ajax response

  29. 29

    How to rewrite table using ajax response

HotTag

Archive