Datatables Example, Jquery Datatable Ajax Get Data

$(document).ready(function() $("#example").DataTable( "ajax": "/analyze/List", "columns": < responsedata: "Name" , responsedata: "Total" , responsedata: "Passed" , responsedata: "Failed" > ); );Didn"t work.Is that not how it"s supposed lớn be done ? .

Bạn đang xem: Datatables example, jquery datatable ajax get data

Here"s the json data format on server-

"responseCode":0,"responseData":<"Name":"Rocky","Total":39,"Passed":35,"Failed":4>Also, I"m an error Uncaught TypeError: Cannot read property "length" of undefined. Could someone help ? I"m a noob in this.

Xem thêm: Dấu Hiệu Tử Cung Mở Sớm - Làm Sao Để Biết Tử Cung Mở Khi Chuyển Dạ



Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)
Yu are doing it a little bit backwards. Use the dataSrc attribute lớn instruct dataTables that the rows is hold by the responseData property, và refer to lớn each field via the data attribute, not responseData :

$("#example").DataTable( ajax: url: "/analyze/List", dataSrc: "responseData" , columns: < data: "Name" , data: "Total" , data: "Passed" , data: "Failed" >)demo ->


Thanks for contributing an answer lớn Stack Overflow!

Please be sure lớn answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding khổng lồ other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy và cookie policy

Not the answer you're looking for? Browse other questions tagged jquery datatables datatables-1.10 or ask your own question.


Site kiến thiết / hình ảnh © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. Rev2022.7.8.42556

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.