Jquery Button Post it's ID

i have the following code which sets the button’s ID


<a href="#confirmation"><button data-inline="true" id="'.$device['name'].'-on">'.$device['name'].' On</button></a>

what i would like is the button when pressed to post the ID value to index.php?id=

This probably a 2 min job for some one on here but i am struggling!


$("button").click(function() {
  alert(this.id);
});

the above does alert the id i am after but no idea how to post the id.

For a form input field, you can only POST the name and the value. If you want to POST any extra data, you’ll need to use a hidden input field.

<input type="hidden" name="somename" value="<?php echo 'somevalue' ?>">

If you’re trying to determine which button was pressed, to check for a button press, use:

<button name="myButtonName">Click Me!</button>
if(isset($_POST['myButtonName'])){
     //do something
}

would an ajax post request work?
i was originally using get but had issues so just want to post the id nothing else.