Цитата:
|
Цитата:
|
Цитата:
Цитата:
я юзаю именно этот полифил Цитата:
Цитата:
моя тупость зашкаливает) |
Цитата:
лично я считаю что даный полифил не хуже своего кода, над ним работаю ребята в 100 раз круче тебя, и они то знают толк в извращениях) |
Цитата:
С другой стороны, если он тебе не нужен, можешь не заморачиваться. Абсолютно по*ю каким форматом сервер обменивается с клиентом, главное, чтобы тебе было удобно. Просто json -- это стандарт. Если ты сам себе хозяин, можешь положить на стандарты. |
Цитата:
Цитата:
![]() я не знаю как принять его) хотя например можно так let result = fetch('server.php?cool=javascript', { method: 'post', headers: { "Content-type": "application/x-www-form-urlencoded" }, body: 'param=' + JSON.stringify({ javascript: 'cool', es_modern: '6 aka 2015', }) }) result.then(function(response) { return response.text() }).then(function(text) { console.log(text) }) } ![]() |
Общем как меня не учи - я делаю так)
function getContent(timestamp) { toQueryString = function(data) { var query = '', i, push = function(key, value) { query += encodeURIComponent(key) + '=' + encodeURIComponent(value) + '&'; }, key, value; for (key in data) { if (!Object.hasOwnProperty.call(data, key)) { continue; } value = data[key]; if ((typeof(data) === "object") && (data instanceof Array)) { for (i = 0; i < value.length; i++) { push(key, value[i]); }; } else { push(key, data[key]); }; }; return query.replace(/&$/, '').replace(/%20/g, '+'); }; var queryString = { 'timestamp': timestamp }; var result = fetch('server.php', { method: 'post', headers: { "Content-type": "application/x-www-form-urlencoded" }, body: toQueryString(queryString) }) result.then(function(response) { return response.json() }).then(function(text) { document.querySelector('#response').innerHTML = text.data_from_file; getContent(text.timestamp); })['catch'](function(ex) { getContent(timestamp); }) } |
Цитата:
|
Цитата:
$data = json_decode(file_get_contents('php://input'), true); Цитата:
|
Цитата:
|
Часовой пояс GMT +3, время: 13:53. |