Error: "Failed to read the 'result' property from 'IDBRequest': The request has not finished" when try to modify in a loop
<p>I´m working with IndexedDB and when I try to modify/edit several values with the same text and using a "FOR" loop it shows me: "Failed to read the 'result' property from 'IDBRequest': The request has not finished".</p>

<p>When I try it with just one value without loops all works fine. This is my actual function:</p>

<pre><code>function modificarModelos(){
      var active = dataBase.result;
      var data = active.transaction(["modelos"], "readwrite");
      var object = data.objectStore("modelos");
      var request;
      for(var key in window.idModelosMarca){
        request = object.get(window.idModelosMarca[key]);
        request.onsuccess = function() {
          var data = request.result;   //---&gt; THE ERROR APPEARS IN THIS LINE
          data.idmarca = document.querySelector("#NuevoNombreMarca").value
          var requestActualizado = object.put(data);
          requestActualizado.onsuccess = function() {
            console.log("Success");
          };
          requestActualizado.onerror = function (e) {
            alert(request.error.name + '\n\n' + request.error.message);
          };
        };
      }
    }
</code></pre>

<p>What can I do to make it work?</p>

<p>Thanks.</p>