Enviado em 20/06/2020 - 12:23h
Estou tetando pegar uma resposta do php usando um requisição fetch mas sempre da undefined o código js é esse:let search = () => { let age = document.querySelector("#age"); selectPlan(); age.addEventListener('onchange', selectPlan()); } const showData = (result) => { for (const field in result) { console.log(field); } } const selectPlan = () => { const options = { method: 'GET', mode: 'cors', cache: 'default' } fetch(`./modules/select.php?age=${age.options[age.selectedIndex].value}`, options) .then(response => { response .then(data => showData(data)); }).catch(e => console.log("Erro: " + console.log(`./modules/select.php?age=${age.options[age.selectedIndex].value}`))) }; window.onload = () => { search(); }
if(!file_exists(require_once('../bd/connection.php'))) require_once('../bd/connection.php'); $connection = connection(); $age = $_GET['age']; $sql = "SELECT * FROM tbl_plans WHERE age_range='$age'"; $select = (mysqli_query($connection, $sql)); $rsSelect = mysqli_fetch_assoc($select); if($rsSelect == null){ return var_dump($sql); } //$rsSelect=json_encode($rsSelect); //var_dump($rsSelect); return $rsSelect;
Como compartilhar a tela do Ubuntu com uma Smart TV (LG, Samsung, etc.)
Descritores de Arquivos e Swappiness
tux-gpt - Assistente de IA para o Terminal
Instalação e configuração do Chrony
Programa IRPF - Guia de Instalação e Resolução de alguns Problemas
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
O Que Fazer Após Instalar Ubuntu 25.04
Erro ao atualizar o archlinux [RESOLVIDO] (2)
Erro ao executar o comando para dar um get email (0)