So nun zum Problem: Die Beschreibungen werden richtig abgerufen (getestet mithilfe von
console.log(currentDescriptions[i];
)) aber i ist hierbei jedesmal 12, also die Länge des Arrays "myArray". Ich persönlich kann mir nur vorstellen, dass die Schleife während dem Request weiterläuft. Wie könnte ich einstellen, dass die Schleife erst nach dem Ende des Requests weiterläuft?
Das schreit nach einem Problem mit Synchroner und Asynchroner Ajax anfrage. Standardmässig ist die Asynchrone Anfrage eingestellt bei jquery. Das heißt, während der Anfrage läuft der Code weiter, so wie du berichtet hast.
http://api.jquery.com/jQuery.ajax/
Zitat:
async
Default: true
By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false is deprecated.
Gruß
der asynchrone
T-Rex