if (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') === 0) {
$_POST = @json_decode(file_get_contents('php://input'), true);
if (!is_array($_POST)) $_POST = [];
}
var nodes = document.querySelectorAll('.className'),
className =' foo',
re = new RegExp('\\s*' + className + '\\s*', 'gi');
for (var i = 0, len = nodes.length; i < len; i++) {
var node = nodes[i];
node.className = node.className.replace(re, ' ').trim();
}
beforeSend
Type: Function( jqXHR jqXHR, PlainObject settings )
A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request.
function api_get () {
$.ajax({
type: "GET",
url: <URL>
crossDomain: true,
dataType: 'json',
data: bundle,
async: false,
timeout: 10000,
beforeSend: function() {
$('#updating').text('loading');
},
success: function (data) {
$('#updating').empty();
/* действия */
}
};