4. El servicio lee los datos
index.html
const datos = {
saludo: "Hola",
nombre: "pp"
}
const respuesta = await consume(
enviaJsonRecibeJson(
"api/json.php", datos))
const json =
await respuesta.json()
alert(json)
Hace wait esperando response.
Memoria
- datos
-
- saludo
- "Hola"
- nombre
- "pp"
api/json.php
$json = leeJson();
$saludo = $json->saludo;
$nombre = $json->nombre;
$resultado =
"{$saludo} {$nombre}.";
devuelveJson($resultado);
Request
POST /api/json.php HTTP/1.1
Accept: application/json, application/problem+json
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: es-MX,es-ES;q=0.9,es;q=0.8,en;q=0.7,gl;q=0.6,pt;q=0.5
Connection: keep-alive
Content-Length: 31
Content-Type: application/json
Cookie: __test=610630da28570bec7a7a24ad4391af68
Host: srvjson.rf.gd
Origin: https://srvjson.rf.gd
Referer: https://srvjson.rf.gd/?i=1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML,
like Gecko) Chrome/148.0.0.0 Safari/537.36
sec-ch-ua: "Chromium";v="148", "Google Chrome";v="148",
"Not/A)Brand";v="99"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
{"saludo":"Hola","nombre":"pp"}
Memoria (Servidor)
- $json
-
- saludo
- "Hola"
- nombre
- "pp"
- $saludo
- "Hola"
- $nombre
- "pp"
skip_previous
skip_next