.each loop are not executed completely ... why ? ( code and log available )
<p>var idd;</p>

<pre><code>$.each(data, function (i, items) { //1st each
    $.each(items, function (j, item) { // 2nd each
        console.log("Field:" + j + " Value:" + item);

        if (j=="sha_id"){ idd=item; }

    });
    console.log("Items");
    console.log("ID:" + idd);

    db.transaction(function (tx) {
        console.log("being inserted");
        console.log("ID Inserting:" + idd);
        //then some database insertion query
</code></pre>

<p>This is sample upper part script </p>

<p>Basically 1st .each will run 2 round and 2nd .each will run two round for each 1st .each</p>

<p>So in console log I expect to see <br />
field .... value <br />
field ..... value <br />
Items <br />
ID : 2 <br />
being inserted <br />
ID Inserting : 2 <br />
field .... value <br />
field ..... value <br />
Items <br />
ID : 3 <br />
being inserted <br />
ID Inserting : 3<br /><br /></p>

<p>But what i am getting is this </p>

<p>field .... value <br />
field ..... value <br />
Items <br />
ID : 2 <br />
field .... value <br />
field ..... value <br />
Items <br />
ID : 3 <br />
being inserted <br />
ID Inserting : 3<br />
being inserted <br />
ID Inserting : 3<br /></p>

<p>Why my db.transaction  is not executed just after console.log("Items") at first as they are in the same loop. Is there any code error i should correct ?</p>
