• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Why will data not bind if success and error are defined – datatables ajax

Resolved: Why will data not bind if success and error are defined – datatables ajax

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

My ajax call is:
…
console.log in “success” gives me the following json array but it is not bound to the datatable

[{reference_id: ‘873’, name: ‘MapTest’, details: ‘Sourced from Open Street Maps’, num_points: 0, num_sections: 23}, {reference_id: ‘899’, name: ‘Albury C roads’, details: ‘Sourced from Open Street Maps’, num_points: 0, num_sections: 0}]


but it is not bound to the table what am I missing?
Update
By removing the success and error properties, data started binding..Why?
enter image description here

Answer:

As you have seen, you should not override the jQuery Ajax success option in your DataTables ajax option.
As documented here:

…the success option of ajax should not be altered – DataTables uses it internally to execute the table draw when the data load is complete.


Use the dataSrc option instead, for any custom processing you may want to do after receiving the JSON response via Ajax.
(I have not experimented with the error property of the DataTables ajax option – it may be the same situation as the success option. It’s not mentioned in the documentation I linked to.)

If you have better answer, please add a comment about this, thank you!

ajax datatable jquery json
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Modify entity using Action in C#

24/03/2023

Resolved: How to give rank on datetime column group by another column with userid in it

24/03/2023

Resolved: Passing 2 functions in onChange in react

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.