cannot click items echoed by another page using ajax - $(document).on is not working
<blockquote>
  <blockquote>
    <p>updated</p>
  </blockquote>
</blockquote>

<p>i'm having 2 pages. An index page connected to a js file. This js file containing ajax code fetching data from database. 
this is my js file</p>

<pre><code>$(document).ready(function() {

    // getting links from db andshow sub_menu div //
    $(".menu_item").mouseover(function(){
        $(this).addClass("selected").children().slideDown(500,function(){
            var id = $(".selected").attr("id");
            var ajax= false;
            ajax = new XMLHttpRequest();
            var qst = "?id="+id;
            ajax.open("GET","ajax/get_sub_cats.php"+qst);
            ajax.onreadystatechange = function(){
                if(ajax.readyState == 4 &amp;&amp; ajax.status == 200){
                    $(".sub_menu[title="+id+"]").html(ajax.responseText);
                }
            }
            ajax.send(null);
        });
    });

    // hiding sub_menu div //
    $(".menu_item").mouseout(function(){
        $(this).removeClass("selected").children(".sub_menu").slideUp(500);
    });

    // keeping sub_menu div visible on mouse over //
    $(".sub_menu").mouseover(function() {
        $(this).stop();
    });

    // clicking sub menu link in the menu //
    $(document).delegate("a#subCatLink","click",function(){
    alert("test");
    }); 
    // document ready end
    });
</code></pre>

<p>and this is get_sub_cats php file used to fetch links from db</p>

<pre><code>&lt;?php
require('../_req/base.php');
$id = $_REQUEST['id'];
$getSubcatsQ = "select * from sub_cats where Main_Cat_ID = '$id'";
$getSubcatsR = mysql_query($getSubcatsQ);
$numrows = mysql_num_rows($getSubcatsR);
while($row = mysql_fetch_array($getSubcatsR)){
    ?&gt;
   &lt;a id="subCatLink" href="products.php?id=&lt;?php echo $row['Sub_Cat_ID']; ?&gt;"&gt;&lt;?php echo $row['Sub_Cat_Name']; ?&gt;&lt;/a&gt;&lt;br /&gt;
    &lt;?php
}
mysql_close($connect);
?&gt;
</code></pre>

<p>clicking links coming from the other php file using ajax is not working at all</p>
