Last active
April 9, 2025 16:50
-
-
Save kurotori/08808cd4444a5b9cfbd9f3f7d6d470f4 to your computer and use it in GitHub Desktop.
Ejemplo de HTML JS y PHP 08 abr 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dato1 = $_POST['dato1']; | |
$dato2 = $_POST['dato2']; | |
echo("Datos recibidos: Dato 1: $dato1 Dato 2: $dato2"); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const formulario = document.getElementById('formulario') | |
const divRespuesta = document.getElementById('respuesta') | |
formulario.addEventListener( | |
'submit', | |
function (evento) { | |
evento.preventDefault() | |
const datosFormulario = new FormData(this) | |
fetch( | |
'destino.php', | |
{ | |
method:'POST', | |
body:datosFormulario | |
} | |
) | |
.then( | |
respuesta =>{ | |
if ( ! respuesta.ok ) { | |
console.log("Pasó algo bro") | |
} | |
return respuesta.text() | |
} | |
) | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<form id="formulario"> | |
<label for="dato1">Dato 1:</label> | |
<input type="text" id="dato1" name="dato1"> | |
<br> | |
<label for="dato2">Dato 2:</label> | |
<input type="text" id="dato2" name="dato2"> | |
<br> | |
<button type="submit">Enviar Datos</button> | |
</form> | |
<div id="respuesta"></div> | |
</body> | |
<script src="funciones.js"></script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment