I would like to get an id from a button. I need this id in my ajax request. This is my button:
<form>
<div class="form-group">
<button class="btn btn-primary" name="deletecar" id="">Delete</button>
</div>
</form>
As you can see, the button id is filled with data from my database.
I'm getting the id of the button this way:
<script type="text/javascript">var JcarID = this.id;</script>
Finally my Ajax Request.
$('[name="deletecar"]').click(function (e)
{
var JcarId = this.id;
e.preventDefault();
$.ajax({
type: "POST",
url: '',
success: function (data)
{
// alert(data);
}
});
});
I would like to set the value of $car->id == JcarId.
Sorry for my bad english,
Thx for reading!
via Koen van de Sande