Hi,
ich lese mittels einer JSP Daten aus einer Oracle Datenbank und gebe diese dann in JSON Syntax zurück. Anschließend hole ich mir diese Daten per Ajax Request in meine Index.html.
Die Daten sehen wie folgt aus:
Nun möchte ich mittels eval() ein JSON Objekt daraus erzeugen...jedoch klappt das ganze nicht.
Wenn ich
schreibe dann erhalte ich eine leere Seite und die Fehlermeldung:
Das komische ist wenn ich die Daten die ich durch den Ajax Request erhalte einfach kopiere und als String in eine Variable lege dann funktioniert folgendes:
ich lese mittels einer JSP Daten aus einer Oracle Datenbank und gebe diese dann in JSON Syntax zurück. Anschließend hole ich mir diese Daten per Ajax Request in meine Index.html.
Die Daten sehen wie folgt aus:
{"CALLSIGN_OTHER_AIRPLANE":["CAJUN02","CAJUN01","JEUS1","JEUS1"],"ALTITUDE_MSL":["14774.7","13837.2","27366","28088.2"],"CALLSIGN":["CAJUN01","CAJUN02","JEUS1","JEUS1"],"H_DIST_IN_METER":["177.91832","177.91832","783.002","783.002"],"V_DIST_IN_FEET":["937.5","937.5","722.2","722.2"],"TIME_OF_DAY_UTC_MS":[null,null,null,null],"TTL":["5","5","5","5"],"MANEUVER":["0","0","0","0"],"LATITUDE":["49.414925","49.416325","48.11217","48.116978"],"SPEED_VERTI_FTMIN":["-8438.63","-8749.04","-498.134","1150.69"],"TIME_STAMP":["1970-01-01 18:49:39.847","1970-01-01 18:49:39.847","1970-01-01 18:49:39.847","1970-01-01 18:49:39.847"],"TIME_LAST_UPDATE_MS":["67777250","67776508","67775813","67775820"],"TIME_TAG_MS":["67779847","67779847","67779847","67779847"],"HEADING_DEG":["193.224","250.908","10.732","9.26098"],"I48_230":[null,null,null,null],"TRACK_ID_OTHER_AIRPLANE":["131","132","565","564"],"LONGITUDE":["7.10975","7.108565","7.22684","7.219151"],"ALTITUDE_AGL":[null,null,null,null],"SPEED_HORI_KT":["176.233","127.898","396.112","415.594"],"TRACK_ID":["132","131","564","565"],"STREAM_ID":["34ed2fe","34ed2fe","34ed2fe","34ed2fe"]}
Nun möchte ich mittels eval() ein JSON Objekt daraus erzeugen...jedoch klappt das ganze nicht.
Wenn ich
var response = http.responseText;
var responseAsJson = eval(response);
document.getElementById("Ausgabe").innerHTML = response;
schreibe dann erhalte ich eine leere Seite und die Fehlermeldung:
syntax error
[Bei diesem Fehler anhalten] var responseAsJson = eval(response);
Das komische ist wenn ich die Daten die ich durch den Ajax Request erhalte einfach kopiere und als String in eine Variable lege dann funktioniert folgendes:
var json_objekt = '{"CALLSIGN_OTHER_AIRPLANE":["CAJUN02","CAJUN01","JEUS1","JEUS1"],"ALTITUDE_MSL":["14774.7","13837.2","27366","28088.2"],"CALLSIGN":["CAJUN01","CAJUN02","JEUS1","JEUS1"],"H_DIST_IN_METER":["177.91832","177.91832","783.002","783.002"],"V_DIST_IN_FEET":["937.5","937.5","722.2","722.2"],"TIME_OF_DAY_UTC_MS":[null,null,null,null],"TTL":["5","5","5","5"],"MANEUVER":["0","0","0","0"],"LATITUDE":["49.414925","49.416325","48.11217","48.116978"],"SPEED_VERTI_FTMIN":["-8438.63","-8749.04","-498.134","1150.69"],"TIME_STAMP":["1970-01-01 18:49:39.847","1970-01-01 18:49:39.847","1970-01-01 18:49:39.847","1970-01-01 18:49:39.847"],"TIME_LAST_UPDATE_MS":["67777250","67776508","67775813","67775820"],"TIME_TAG_MS":["67779847","67779847","67779847","67779847"],"HEADING_DEG":["193.224","250.908","10.732","9.26098"],"I48_230":[null,null,null,null],"TRACK_ID_OTHER_AIRPLANE":["131","132","565","564"],"LONGITUDE":["7.10975","7.108565","7.22684","7.219151"],"ALTITUDE_AGL":[null,null,null,null],"SPEED_HORI_KT":["176.233","127.898","396.112","415.594"],"TRACK_ID":["132","131","564","565"],"STREAM_ID":["34ed2fe","34ed2fe","34ed2fe","34ed2fe"]} ';
var o = eval("(" + json_objekt + ")");
document.getElementById("Ausgabe2").innerHTML = o.CALLSIGN_OTHER_AIRPLANE;
Zuletzt bearbeitet: