-1
I have a form in html that receives a zip code, and is sent (action) to my class in PHP, which returns the address and I wanted to take this return address and put in my html page, but I don’t know how to do it with javascript.
html:
<header class="header">
        Cabeçalho! Faça suas pesquisas aqui!
</header>
<article class="busca">
     <form class="form" method="POST" action="ControllerTeste.php">
          CEP: <input class ="cep" type="text" name="cep" placeholder="Insira o cep" required/>
          <input class="submit" type="submit" value="Buscar"/>
     </form>
</article>
<article class="data">
        <!--Dados PHP via JS-->
</article>
PHP:
<?php
Class Controller{
    public $cep;
    public function ConsultaViaCEP(){
        $cep = Controller::setFormCEP();
        $cep = preg_replace("/[^0-9]/", "", $cep);
        $url = file_get_contents("http://viacep.com.br/ws/$cep/json/");
        $json = json_decode($url, true);
        return $json;
    }
    [...getters and setters]
    private function setFormCEP(){
        $formCEP = $_POST['cep'];
        return $formCEP;
    }
}
    echo Controller::getCEP()."<br>";
    echo Controller::getLogradouro()."<br>";
    echo Controller::getComplemento()."<br>";
    echo Controller::getBairro()."<br>";
    echo Controller::getLocalidade()."<br>";
    echo Controller::getUF()."<br>";
?>
It was for studies, but it was already solved. I was already aware of this, but I can really do it directly by javascript
– Anderson
By the way, how can I delete my questions?
– Anderson