Note that there are some explanatory texts on larger screens.

plurals
  1. POcannot click items echoed by another page using ajax - $(document).on is not working
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload