Wie kann ich auf das Objekt/Array zugreifen?
bearbeitet von
Hallo ebody,
api.jquery.com sagt zu dataType in $.ajax: (fett von mir)
> dataType (**default: Intelligent Guess** (xml, json, script, or html))
> Type: String
> The type of data that you're expecting back from the server. **If none is specified, jQuery will try to infer it based on the MIME type of the response** (an XML MIME type will yield XML, (…) JSON will yield a JavaScript object, (…) script will execute the script, and anything else will be returned as a string).
D.h. wenn Du in jQuery sagst, dass er die Response als JSON interpretieren soll, ist es wurscht, was der Server liefert. Es ist aber trotzdem guter Stil, wenn ein Server seinen Content mit dem richtigen Content-Type ausliefert. Für den Fall, dass mal jemand anderes als jQuery die Daten holt (z.B. das fetch API).
_Rolf_
--
sumpsi - posui - obstruxi