Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery will not work in file retrieved by java select include
    text
    copied!<p>I have a simple form that that when changed includes a php file in a div. For some reason jquery will not load when placed in that included file? Can someone tell me why this doesnt work. </p> <pre><code> &lt;select name='make' onChange='show(this.value)'&gt; &lt;option value='some-file.php'&gt;the file&lt;/option&gt; &lt;/select&gt; &lt;div id="make"&gt;Where the file is loaded and where jquery wont work&lt;/div&gt; &lt;script type="text/javascript"&gt; function show(str) { if (str=="") { document.getElementById("make").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("make").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","include/some-file.php?q="+str,true); xmlhttp.send(); } &lt;/script&gt; </code></pre> <p>Then some-file.php</p> <pre><code> $models = mysql_query("SELECT model, id FROM model where make like '%".$q."%' order by model asc") or die(mysql_error()); //Puts it into an array $count = 1; $max = 3; while($model = mysql_fetch_array( $models )) { if($count%20==1) echo '&lt;/ul&gt;&lt;ul style="float:left; padding:0; margin-right:10px;" class="makesModels"&gt;'; echo "&lt;li style='padding-right:5px; display:block;'&gt;&lt;font color='#fe9000'&gt;".$count.".&lt;/font&gt; ".$model['model']."&amp;nbsp;&lt;a class='delete-model".$model['id']."'&gt;x&lt;/a&gt;&lt;/li&gt;"; &lt;script type='text/javascript' src='http://code.jquery.com/jquery-1.8.1.min.js'&gt;&lt;/script&gt; &lt;script type='text/javascript'&gt; $(docuument).ready(function() { $(".delete-model&lt;? echo $model['id'];?&gt;").click(function() { alert("delete"); }); }); &lt;/script&gt; $count++; } ?&gt; </code></pre>
 

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