Table is "Loading..." infinite
Table is "Loading..." infinite
My table in index.html is loading all the time ans does ot display the data from 'table.php' that i created by the php function json_encode().
table.php:
[{"id":"2","0":"2","vorname":"Max","1":"Max","nachname":"Mustermann","2":"Mustermann","strasse-hsnr":"Musterstra\u00dfe 5","3":"Musterstra\u00dfe 5","plz":"12345","4":"12345","ort":"Musterstadt","5":"Musterstadt","tel-1":"0123 456789","6":"0123 456789","tel-2":"456 789321","7":"456 789321","e-mail":"max@muster.mann","8":"max@muster.mann","bemerkungen":"Bemerkungen:\r\nMax ist ein netter Kunde","9":"Bemerkungen:\r\nMax ist ein netter Kunde"}]
index.html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
</head>
<body>
<script>
$(document).ready(function(){
$('#personen').DataTable({
ajax: 'table.php',
columns: [
{ data: 'id' },
{ data: 'vorname' },
{ data: 'nachname' },
{ data: 'ort' }
]
});
});
</script>
<table id="personen" class="display">
<thead>
<tr>
<th>ID</th>
<th>Vorname</th>
<th>Nachname</th>
<th>Ort</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>Vorname</th>
<th>Nachname</th>
<th>Ort</th>
</tr>
</tfoot>
</table>
</body>
</html>
Sorry for the all German words but i want to show you the original code
Maybe you can help me detecting the problem
Answers
I suspect a JS error has occurred on the page. If you look at the browser's console, what does it say?
Allan
It says:
http://my.url.com/path/:20:17
mightThrow@https://code.jquery.com/jquery-3.5.1.js:3762:29
https://code.jquery.com/jquery-3.5.1.js:3830:12
setTimeout handlerhttps://code.jquery.com/jquery-3.5.1.js:3868:16
fire@https://code.jquery.com/jquery-3.5.1.js:3496:31
fireWith@https://code.jquery.com/jquery-3.5.1.js:3626:7
fire@https://code.jquery.com/jquery-3.5.1.js:3634:10
fire@https://code.jquery.com/jquery-3.5.1.js:3496:31
fireWith@https://code.jquery.com/jquery-3.5.1.js:3626:7
ready@https://code.jquery.com/jquery-3.5.1.js:4106:13
completed@https://code.jquery.com/jquery-3.5.1.js:4116:9
EventListener.handleEventhttps://code.jquery.com/jquery-3.5.1.js:4132:11
https://code.jquery.com/jquery-3.5.1.js:36:10
https://code.jquery.com/jquery-3.5.1.js:40:4
undefined
Uncaught ReferenceError: data is not defined
Uncaught TypeError: l is undefined
Yep, so you'll need to fix those. If you link to your page, we can take a quick look if that would help,
Colin
Actually I can't show you the original data but maybe you can copy my html and json from above and try it yourself..... it would be really helpful!
You can use dummy data in a test case.
https://datatables.net/manual/tech-notes/10
Well, in the testcase (http://live.datatables.net/pugoyoni/1/edit?html,js,output) i can't use ajax and if i use data input directly over a variable, it works somehow.... but ajax is still a problem
The problem with your test case is that it was missing jQuery and your script was preventing it from running - fixing both gives this: http://live.datatables.net/pugoyoni/4/edit
We really need to see the problem you want support with to be able to progress this,
Colin
So, now i have created a copy of my documents:
http://share.gehmasse.de/baheigneiflpalxbent/
What is 'table.php'?
the file includes the following ajax data:
[{"id":"2","0":"2","vorname":"Max","1":"Max","nachname":"Mustermann","2":"Mustermann","strasse-hsnr":"Musterstra\u00dfe 5","3":"Musterstra\u00dfe 5","plz":"12345","4":"12345","ort":"Musterstadt","5":"Musterstadt","tel-1":"0123 456789","6":"0123 456789","tel-2":"456 789321","7":"456 789321","e-mail":"max@muster.mann","8":"max@muster.mann","bemerkungen":"Bemerkungen:\r\nMax ist ein netter Kunde","9":"Bemerkungen:\r\nMax ist ein netter Kunde"}]
Your JSON is not identified as "data".
See the Ajax example:
https://datatables.net/examples/data_sources/ajax.html
ouu, thank you very much! now it works