JavaScript AJAX Progress-Bar?

2 Antworten

Vom Fragesteller als hilfreich ausgezeichnet

Das ProgressEvent zu nutzen ist an der Stelle nicht verkehrt und du findest auch leicht Beispiele dazu:

Allerdings muss die Länge der zu ladenden Ressource auch bekannt sein. Dafür wird die Content-Length-Information aus dem Response Header bezogen.

If the length of the HTTP entity body is known through the Content-Length header, initialize the lengthComputable attribute to true and initialize the total attribute to the length.

Quelle

Diese Angabe wirst du nicht finden, wenn der Server den Response eh bereits in Häppchen aufteilt.

If a Content-Length header field (section 14.13) is present, its decimal value in OCTETs represents both the entity-length and the transfer-length. The Content-Length header field MUST NOT be sent if these two lengths are different (i.e., if a Transfer-Encoding header field is present). If a message is received with both a Transfer-Encoding header field and a Content-Length header field, the latter MUST be ignored.

Quelle

Prüfe also zunächst, welche Informationen dir dein Server bei Anfrage schickt.