JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<div class="button-wrapper">
<button id='firstButton'>
first button
</button>
<button id='secondButton'>
second button
</button>
</div>
CSS
.button-wrapper > button {
text-transform: uppercase;
margin-bottom: 20px;
width: 100%;
}
JavaScript
$("button").click(function(e) {
var targetId = event.target.id;
$.ajax({
type: "GET",
crossDomain: true,
dataType: 'jsonp',
url: "https://jsfiddle.net",
success: function(data) {
alert('target id is: ' + targetId);
},
bullshit: targetId
});
});
// Is it possible for this to work the same as the above somehow?
$(document).ajaxSuccess(function(event, xhr, ajaxOptions, data) {
var targetId = event.target.id; // Event.target is `document` so does not work
alert('target id is: ' + ajaxOptions.bullshit); // I want this to be the same alert as above.
});