jquery.load() didnt work at the first click when the button is clicked for the first time
<p>I have a button that once u click, it will insert a new row to the existing table. Problem that i faced is i have to click twice for the first time for new row will be inserted. But after that, every time you click once, the row will be inserted.</p>

<p>button:</p>

<pre><code>&lt;input type="button" id="add_po_item" name="add_po_item" value="Add Next PO Item" class="btn" style="width:150px; visibility:visible" onclick="addStock(this, '&lt;?php echo $prod_id; ?&gt;', '&lt;?php echo $poid; ?&gt;'); "&gt;
</code></pre>

<p>javascript function to add new row:</p>

<pre><code>function addStock(obj, stock_id, poid)
{
        var inputs = document.getElementById('counter').value*1;
        var elemName = "hid"+inputs; 

        if(obj.id == 'add_po_item')
        {
            $('#' + elemName).load("grn_additem.php", { inputs: inputs, stock_id: stock_id, poid: poid } );
        }

        inputs++;
        var table = document.getElementById("add");
        var elem = document.createElement("tr");
        elem.id = "hid" + inputs;
        table.appendChild(elem);

        document.getElementById('counter').value = inputs;
}
</code></pre>

<p>content in grn_additem.php</p>

<pre><code>&lt;td width="144"&gt;&lt;input type="text" id="ttlM3_&lt;?php echo $ctr; ?&gt;" name="ttlM3_&lt;?php echo $ctr; ?&gt;" readonly="readonly" style="border:none; text-align:center" value="0" /&gt;&lt;/td&gt;
&lt;td width="144"&gt;&lt;input type="text" id="m31_&lt;?php echo $ctr; ?&gt;" name="m31_&lt;?php echo $ctr; ?&gt;" onkeyup="calcM3('&lt;?php echo $ctr; ?&gt;')" /&gt;&lt;/td&gt;
&lt;td width="144"&gt;&lt;input type="text" id="m32_&lt;?php echo $ctr; ?&gt;" name="m32_&lt;?php echo $ctr; ?&gt;" onkeyup="calcM3('&lt;?php echo $ctr; ?&gt;')" /&gt;&lt;/td&gt;
&lt;td width="144"&gt;&lt;input type="text" id="m33_&lt;?php echo $ctr; ?&gt;" name="m33_&lt;?php echo $ctr; ?&gt;" onkeyup="calcM3('&lt;?php echo $ctr; ?&gt;')" /&gt;&lt;/td&gt;
&lt;td width="45"&gt;&amp;nbsp;&lt;/td&gt;
&lt;td width="144"&gt;&lt;input type="text" id="matchcolor&lt;?php echo $ctr; ?&gt;" name="matchcolor&lt;?php echo $ctr; ?&gt;" readonly="readonly" style="background-color:#FF0000" /&gt;&lt;/td&gt;
</code></pre>
