response = await (await fetch('https://jsonplaceholder.typicode.com/users')).json();
console.log(response);
async function func() {
const response = await fetch('https://jsonplaceholder.typicode.com/users');
return await response.json();
}
console.log(await func());
function fastOrder(product_id) {
$('body').prepend(`<section class="fastorder-custf">
<div class="ajax_result">
<i class="fa fa-spinner fa-pulse overlay__icon" aria-hidden="true"></i>
</div>
</section>`);
$('.mfp-close').trigger('click');
$.ajax({
url: 'index.php?route=order/getForm',
type: 'POST',
contentType: 'application/json; charset=UTF-8',
data: product_id,
dataType: 'html',
success: function(response) {
$('.ajax_result').html('Ответ сервера: ' + response);
},
error: function(xhr, status) {
$('.ajax_result').html('При отправке запроса произошла ошибка, детали см. в консоли');
console.log('При отправке запроса произошла ошибка:');
console.dir(xhr);
}
});
}
(async function() {
response = await (await fetch('https://opentdb.com/api.php?amount=10&category=23&difficulty=easy&type=boolean')).json();
console.log(response);
})();
response
будет лежать ответ сервера. Чтобы получить доступ к каким-то конкретным свойствам используйте квадратные скобки, например response['result']
или response['response_code']
response['result']
можете использовать цикл for
document.wrappedJSObject.write(''); document.close();
document.wrappedJSObject.write(''); document.close();
<?php
// Если мы получили GET-запрос:
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
header('Location:/', TRUE, 301); // Переадресуем на главную
}
// Если мы получили POST-запрос:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Выводишь данные, которые нужны
}
$(function () {
$("#show").one('click', function () {
$("#container").html('<iframe src="page.html"></iframe>');
});
});
$.get('/index.html').done(function(html) {
var doc = new DOMParser().parseFromString(html, 'text/html'); // Парсим документ
var body = $('body', doc).html(); // Из документа берем содержимое тега body
$('#news_links_array').html(body); // Вставляем содержимое body куда надо
});