Hollo,
ich benötige etwas Hilfe bei einem Ajax-Request
Ich fordere ein sehr großes Array (3335 Elemente lang) von PHP nach JS an und bekomme die Fehlermeldung
"JSON.psrse: unexpected end of data at line1 column 1 of the JSON data" und ich kann den Fehler nicht sorecht konstruieren und hoffe auf Eure Hilfestellungen
(s. Ausgabe auf der Konsole unten)
Konsolenausgabe:
ich benötige etwas Hilfe bei einem Ajax-Request
Ich fordere ein sehr großes Array (3335 Elemente lang) von PHP nach JS an und bekomme die Fehlermeldung
"JSON.psrse: unexpected end of data at line1 column 1 of the JSON data" und ich kann den Fehler nicht sorecht konstruieren und hoffe auf Eure Hilfestellungen
(s. Ausgabe auf der Konsole unten)
Javascript:
$.ajax({
url: "ajax/getPlanungen",
data: {
'K_ID': global_K_ID,
'timestamp': timestamp
}
}).done(function (data) {
console.log('Array: '+data);
arrUserCalData = JSON.parse(data);
console.log("Array2: "+arrUserCalData);
}).fail(function(jqXHR, textStatus, errorThrown){
console.log('Ajax error on importing importMA: '+textStatus+' InfoErr: '+errorThrown);
});
PHP:
...
// getPlanung holt alle Planungsdaten via MySQLi aus einer Datenbanktabelle -> return ist ein zweidimensionales Array
$list = $planungen->getPlanungen($M_ID, $K_ID, $StartDatum, $EndDatum, null, $timestamp);
if(!empty($list) && is_array($list ) && count($list ) > 0){
echo json_encode($list, JSON_UNESCAPED_UNICODE);
exit();
}else echo null;
Konsolenausgabe:
Code:
//Ausgabe 1
Array: {"0": {"Arbeitszeit": 5, "Notiz": "", "P_ID": 49038, "date": "2018-03-05", "KSTD_ID": 0, "Status": 1, "Kürzel": "U", "user_id": 1070,
"Kundenname": null, "KundenId": null, "Kundenkürzel": null, "type": null, "KVA_ID": null, "Standort": null, "Standortkürzel": null,
"Ben_schrift": 0, "Ben_tele": 0, "Ben_elekt": 0, "KürzelSchicht": null, "SchM_ID": null, "Std_gep": 0, "KB_ID": 0, "Kundenbereich": null, "KBKürzel": null},
[...]
"3334": {"Arbeitszeit": 7.5, "Notiz": "", "P_ID": 73603, "date": "2018-03-18", "KSTD_ID": 4, "Status": 0, "Kürzel": null, "user_id": 2393,
"Kundenname": "MBack", "KundenId": 15, "Kundenkürzel": "MB", "type": "ANÜ", "KVA_ID": 1, "Standort": "Waren", "Standortkürzel": "War",
"Ben_schrift": 0, "Ben_tele": 0, "Ben_elekt": 0, "KürzelSchicht": "FS", "SchM_ID": 1, "Std_gep": 1, "KB_ID": 0, "Kundenbereich": null, "KBKürzel": null} }
//Ausgabe 2
Array2 :
Object(3335)
[0..99]
0:{...}
Arbeitszeit: 5
Ben_elekt: 0
Ben_schrift: 0
Ben_tele: 0
"KBKürzel": null
KB_ID: 0
KSTD_ID: 0
KVA_ID: null
KundenId: null
Kundenbereich: null
"Kundenkürzel": null
Kundenname: null
"Kürzel": "U"
"KürzelSchicht": null
Notiz: ""
P_ID: 49038
SchM_ID: null
Standort: null
"Standortkürzel": null
Status: 1
Std_gep: 0
date: "2018-03-05"
type: null
user_id: 1070
<prototype>: Object { … }
[...]
[3300…3334]
[...]
3334: Object { Arbeitszeit: 7.5, P_ID: 73603, date: "2018-03-18", … }
<prototype>: Object { … }