Nuestro conocimiento compartido. Nuestro tesoro compartido. Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 2 3 4 function enviarJson() {5  var nombre = document.getElementById('nombre');6  var apellidos = document.getElementById('apellidos');7  8  var json = {9  "nombre": nombre.value,10  "apellidos": apellidos.value,11  };12  13  var data = JSON.stringify(json);14  15  16  17  var xhr = new XMLHttpRequest();18  xhr.open("post", "http://localhost:8080/esto-lleva-json-en-el-body", true);19  xhr.send(data);20  21  22 }


Este ShareCode tiene versiones:
  1. Enviar JSON ... (18/09/2021)
Enlace
El enlace para compartir es: