Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery, php and Ajax issue: Can't make dynamic link load dynamic content
    primarykey
    data
    text
    <p>There's a great <a href="http://www.ibm.com/developerworks/opensource/library/os-php-jquery-ajax/index.html" rel="nofollow noreferrer">tutorial on IBM's website</a> which walked me through a simple search/results list using jQuery,PHP and Ajax. </p> <p>I was able to make it work and it's really cool.</p> <p>One problem. I want the results to be hyperlinks and I can't get any java script to run on the results. </p> <p>Here is the script I have (includes what was in the tutorial plus the additional script necessary to ovverride the hyperlink, click behavior):</p> <pre><code>&lt;script type='text/javascript'&gt; $(document).ready(function(){ $("#search_results").slideUp(); $("#search_button").click(function(e){ e.preventDefault(); ajax_search(); }); $("#search_term").keyup(function(e){ e.preventDefault(); ajax_search(); }); $("a").click(ClickInterceptor); }); function ajax_search(){ $("#search_results").show(); var search_val=$("#search_term").val(); $.post("./find.php", {search_term : search_val}, function(data){ if (data.length&gt;0){ $("#search_results").html(data); } }) } function ClickInterceptor(e) { window.alert("Hellow World!"); return false; } &lt;/script&gt; </code></pre> <p>If i put the following html under the <code>&lt;body&gt;</code> tag:</p> <pre><code>&lt;a href="test"&gt;this will work&lt;/a&gt; </code></pre> <p>That will display the alert window.</p> <p>However, if I change the results to hyperlinks (found in <strong>find.php, listing 7</strong> from the tutorial):</p> <pre><code>$string .= "&lt;a href=\"test\"&gt;".$row-&gt;name."&lt;/a&gt; - "; </code></pre> <p>It does not work.</p> <p>Any idea on how to fix this?</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    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