Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple Jquery events on one page
    primarykey
    data
    text
    <p>I am quite new to Jquery and need help trying to get a few events to run on the same page. I have two sections of events, one is a .get which passes data to a file and then displays retrieved data, this happens on page load. The second section is on click events which send and receive data when a button is clicked.</p> <p>These events all work as needed, but if I have both sections on one page the on click events do not work. Below is the code I have and I hope someone knows how to get them all to work? Thanks</p> <pre><code>&lt;script type="text/javascript"&gt; $.get("/layout/standard/check.php", { url: "domain"}, function(data){ $("#content-area").html(data) }); $(".discuss").click( function() { $.post('/layout/standard/report-action.php', {form: "discuss"},function(data){ $(".message").html(data); $(".message").show("slow"); }); }); $(".request").click( function() { $.post('/layout/standard/report-action.php', {form: "request"},function(data){ $(".message").html(data); $(".message").show("slow"); }); }); $(".report").click( function() { $.post('/layout/standard/report-action.php', {form: "report"},function(data){ $(".message").html(data); $(".message").show("slow"); }); }); &lt;/script&gt; </code></pre> <hr> <p>I believe that I have found why it's not working, the onclick links are put on the page by the get event. It would appear that the buttons work if they're already on the page but not if they are inserted this way.</p> <p>This doesn't make sense to me as the buttons are still acting as links with no problem...</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.
    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