I am trying to execute a javascript script but I am not sure how to do this. I usually work in PHP but for this specific thing I needed to implement some javascript. On my website I have a couple of buttons with different ID's. When a button gets pushed, a javascript will run. Inside the javascript the ID will be used to execute a php page. Right now I am using the button to delete a certain thing.
For instance, let's say I push the button with ID= 20. Then I would need the page to run the follow script:
$("button").click(function() {
$.get("example.php?id=(this.id)");
});
As you can see I am trying to execute the page example.php?id=20 but this is somehow not working and I have no idea how I would fix this. Is there a different way to solve this problem? Btw, I use this as button
<button id="<?php echo $id; ?>" class="btn btn-primary sweet-4" onclick="_gaq.push(['_trackEvent', 'example', 'try', 'sweet-4', 'this.id']);">Test</button>
There are some more things happening here, but the main thing I want happening is getting the ID. Thanks in advance.