Entradas

Mostrando entradas de agosto, 2023

CRUD FETCH FULL CON SELECT OPTION JS PHP MYSQL API JSON

 index.php <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">   <meta name="viewport" content="width=device-width, initial-scale=1.0">   <meta http-equiv="X-UA-Compatible" content="ie=edge">   <title>PHP & JavaScript Fetch CRUD</title>   <link rel="stylesheet" href="css/style.css"> </head> <body>   <div id="main">     <div id="header">       <h2>PHP & JavaScript Fetch CRUD</h2>       <div id="search-bar">         <label>Search :</label>         <input type="text" id="search" onkeyup="load_search()" autocomplete="off">       </div>     </div>          <div id="table-data">       <h3>All Records</h3>       <button class="add_new" o...

CÓMO ENVIAR DATOS EN SOLICITUDES GET Y POST CON JAVASCRIPT FETCH API JSON

 Sending Requests with Fetch API To send a GET request with Fetch API, use the following code: fetch( 'https://domain.com/path/?param1=value1&param2=value2' )     .then( response => response.json() )     .then( response => {         // Do something with response.     } ); To send a POST request, use the following code: const params = {     param1: value1,     param2: value2;  }; const options = {     method: 'POST',     body: JSON.stringify( params )   }; fetch( 'https://domain.com/path/', options )     .then( response => response.json() )     .then( response => {         // Do something with response.     } ); You can see the main difference between GET and POST requests is how the parameters are passed to the fetch call. In most cases, developers expect to pass an object of parameters and send requests in a beau...

CODIGOS SELECT OPTION FETCH JAVASCRIPT API JSON PHP MYSQL GET POST

    var formdata = {       'fid' : id     }     datos = JSON.stringify(formdata);     fetch("editar.php", {         method: "POST",         body: datos,         headers: {         'Content-type' : 'application/json',         }        }).then(response => response.json()).then(response => {                /* idp.value = response.id;         codigo.value = response.codigo;         producto.value = response.producto;         precio.value = response.precio;         cantidad.value = response.cantidad;         registrar.value = "Actualizar" */ console.log(response); console.log(response.id); console.log(response.nombre); console.log(response.precio); document.getElementById('edi...