JSFiddle - React, Tailwind, and code Playground
HTML
<button id="send">Send Request</button>
<br/><br/>
<div id="results"></div>
JavaScript
$(function() {
$.ajaxSetup({
beforeSend: function(xhr) {
var newUrl = this.url;
if (newUrl.indexOf("?") != -1) {
newUrl = newUrl + '&jquery=true';
} else {
newUrl = newUrl + '?jquery=true';
}
xhr.open(this.type, newUrl, this.async);
}
});
$('#send').click(function() {
$('#results').load('/ajax_json_echo/?get_data=data');
});
});