AJAX Using DataTables

Hi Brother,
First of all, I would like to thank you for such a beautiful and stable working theme.

But I'm Having a Little Problem
Below I Share HTML and JS Content, I Fill Content With Ajax

<div id="YetkiTanimlariListeAlani" class="docs-content flex-column flex-column-fluid">
<div class="container d-flex flex-column flex-lg-row">
<div class="card card-docs flex-row-fluid mb-2">
<div class="card-body">
<div class="table-responsive">
<table id="YetkiTanimlariListeTablosu" class="table table-rounded border gy-7 gs-7 DT_TabloYapisi">
<thead>
<tr id="YetkiTanimlariListeTablosu_Baslik" class="fw-semibold fs-6 text-gray-800 border-bottom-2 border-gray-200">
</tr>
</thead>
<tbody id="YetkiTanimlariListeTabloIcerigi">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

I'm Using An HTML Table Like This

var ListeIcerigi = jQuery.parseJSON(GelenVeri);
if (ListeIcerigi.length > 0) {
ListeKayitSayisi = ListeIcerigi.length;

$("#YetkiTanimlariListeTablosu > thead > tr").empty();
$("#YetkiTanimlariListeTablosu > tbody").empty();
var _YetkiTanimlariListeTablosuTH1 = document.createElement('th');
var _YetkiTanimlariListeTablosuTH2 = document.createElement('th');
_YetkiTanimlariListeTablosuTH1.innerHTML = "Veri Tanımı";
_YetkiTanimlariListeTablosuTH2.innerHTML = "Açıklama";
_TB_YetkiTanimlariListeTablosuTR.appendChild(_YetkiTanimlariListeTablosuTH1);
_TB_YetkiTanimlariListeTablosuTR.appendChild(_YetkiTanimlariListeTablosuTH2);
$.each(ListeIcerigi, function (Anahtar, Deger) {
$("table #YetkiTanimlariListeTabloIcerigi").append(
"<tr id=YetkiTanimlariListeTabloIcerigi_" + Deger.KayitNo + ">" +
"<td>" + Deger.VeriTanimi + "</td>" +
"<td>" + Deger.Aciklama + "</td>" +
"<tr>"
);
});
}

I Fill Content With Ajax Like This
Class with DT_TabloYapisi I Converted for DataTables, I Used Class Instead of ID

Only When I Fill Content With Ajax In This Way, An Error Occurs On The Console


datatables.bundle.js:1517 Uncaught TypeError: Cannot read properties of undefined (reading 'aDataSort')
at qA (datatables.bundle.js:1517:53)
at nt (datatables.bundle.js:1592:17)
at z (datatables.bundle.js:204:25)
at HTMLTableElement. (datatables.bundle.js:228:110)
at Function.each (plugins.bundle.js:15:3320)
at _.fn.init.each (plugins.bundle.js:15:1461)
at _.fn.init.a [as dataTable] (datatables.bundle.js:108:21)
at A.fn.DataTable (datatables.bundle.js:3299:24)
at Object.init (advanced.js:87:38)
at HTMLDocument. (advanced.js:140:26)

There Is A Function As Below In The Related Field

function qA(t) {
var e, r, i, o, s, c, B, g = [],
l = t.aoColumns,
w = t.aaSortingFixed,
u = A.isPlainObject(w),
h = [],
E = function (t) {
t.length && !Array.isArray(t[0]) ? h.push(t) : A.merge(h, t)
};
for (Array.isArray(w) && E(w), u && w.pre && E(w.pre), E(t.aaSorting), u && w.post && E(w.post), e = 0; e < h.length; e++)
for (r = 0, i = (o = l[B = h[e][0]].aDataSort).length; r < i; r++) c = l[s = o[r]].sType || "string", h[e]._idx === n && (h[e]._idx = A.inArray(h[e][1], l[s].asSorting)), g.push({
src: B,
col: s,
dir: h[e][1],
index: h[e]._idx,
type: c,
formatter: a.ext.type.order[c + "-pre"]
});
return g
}

Search Field Doesn't Work When I Remove This Function
How Can I Arrange the Table According to Ajax and DataTables?
Please Can You Help Me?

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)

I Solved The Problem, The Cause Of The Error Is Due To Creating The Table Header On Js

Hi happy,

Glad to hear that. All the best with your project. Please let us know if you need any further help.

Regards.

Your Support Matters!

We will highly appreciate your Metronic Review on Themeforest.
Please go to Themeforest Downloads page, select Metronic & leave your feedback.
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(