Deprecation Notice:
The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.
new Promise(send).then(
function (data) {
// И вот тут получаем данные
},
function () {
// Провал
}
);
function send (metod, url, value, header) {
var p = new XMLHttpRequest(),
body = null;
if (metod && metod.toLoweCase() == 'post') {
body = value;
p.setRequestHeader('Content-Type', header || 'application/x-www-form-urlencoded');
}
p.open(metod, url);
p.send(body);
p.addEventListener('readystatechange', function() {
if (this.readyState === this.DONE && this.status >=200 && this.status < 400) {
resolve(JSON.parse(this.responseText));
} else {
reject();
}
});
}
send();
function send (metod, url, value, header) {
$.ajax({
url: url,
type: metod,
data: value,
dataType: 'json'
}).done(function (data) {
// И вот тут получаем данные
}).error(function () {
// Провал
});
}
<iframe name="test"></iframe>
$(function () {
$.ajax({
url: '...'
}).done(function (data) {
frames.test.document.open();
frames.test.document.write(data);
frames.test.document.close();
});
});
.round-trigger:hover .icon-add {
// Тут всё, что нужно
}
.round-trigger.round-edit .icon-add {
// Тут всё, что нужно
}
$('.round-trigger').hover(
function () {
$('.icon-add', this).addClass('round-edit');
},
function () {$(
'.icon-add', this).removeClass('round-edit');
}
);
(function () {
var sendObject = {};
document.addEventListener('input', function (e) {
if (e.target.name == 'login') {
clearTimeout(sendObject.timer);
sendObject = {
target: e.target,
timer: setTimeout(send, 500)
};
}
});
function send () {
console.log(sendObject.target.value);
}
})();
var startString = '2015:7:11:13:27:12',
startTime = '1439299632000'; // Соответствует указанной выше дате
new Date(Date.UTC.apply(null, startString.split(':')));
new Date(parseInt(startTime));
var newstimer = window.setInterval('news();', 15000);
setTimeout(news, 15000);
$(document).on('click', '#connect', function () {
myHub.server.connect('@Model.Id');
});
$(document).on('submit', '.send_form', function (e) {
var input = this.name;
});
<script src="..." async></script>
var script = document.createElement('script');
script.src = '...';
script.async = true;
document.head.appendChild(script);
if (document.readyState != 'loading') {
// Делаем что нужно
} else {
document.addEventListener('DOMContentLoaded', function () {
// Делаем что нужно
});
}
for (var i = 0, result = []; i < arr.length; i++){
for (var j = 0, _result = []; j < arr[i].length; j++){
_result.push({
t: i == 0 ? null : arr[i][j] === arr[i - 1][j],
tr: i == 0 || j == arr[i].length - 1 ? null : arr[i][j] === arr[i - 1][j + 1],
r: j == arr[i].length - 1 ? null : arr[i][j] === arr[i][j + 1],
br: i == arr.length - 1 || j == arr[i].length - 1 ? null : arr[i][j] === arr[i + 1][j + 1],
b: i == arr.length - 1 ? null : arr[i][j] === arr[i + 1][j],
bl: i == arr.length - 1 || j == 0 ? null : arr[i][j] === arr[i + 1][j - 1],
l: j == 0 ? null : arr[i][j] === arr[i][j - 1],
tl: i == 0 || j == 0 ? null : arr[i][j] === arr[i - 1][j - 1]
});
}
result.push(_result);
}
console.log(JSON.stringify(result));
for (var i = 0, result = []; i < arr.length; i++){
for (var j = 0, _result = []; j < arr[i].length; j++){
var status = !!arr[i][j];
if (!status) {
status = arr[i][j] === arr[i][j - 1] || arr[i][j] === arr[i][j + 1];
if (!status && i != 0) {
status = arr[i][j] && (arr[i][j] === arr[i - 1][j - 1] || arr[i][j] === arr[i - 1][j] || arr[i][j] === arr[i - 1][j + 1]);
} else if (!status && i != arr.length - 1) {
status = arr[i][j] && (arr[i][j] === arr[i + 1][j - 1] || arr[i][j] === arr[i + 1][j] || arr[i][j] === arr[i + 1][j + 1]);
}
}
_result.push(status);
}
result.push(_result);
}
console.log(JSON.stringify(result));