Sending of ZEND email

Asked

Viewed 55 times

2

A client wants me to create a form that sends data to a link, from what I saw, is using "zend", I never got to use this framework and I’m a bit bewildered.

That was his message:

Para realizar a simulação, é necessário chamar o endereço http://simulador.consclic.com.br/simula , passando por POST os seguintes campos:

        Segmento (código do segmento)
        TxtValor_Min
        TxtValor_Max
        modocalculo ("credito" ou "parcela")
        TxtTelefone (Telefone com DDD embutido)
        TxtNome
        TxtEmail
        TxtCidade (passar o código do CEP no formato 99999-999)
        txtContato ("1" = agendar, "0" = não agendar)
        rdMomento ("agd" = Agendado ou "imd" = Imediato) 
        contatoMomento (data e hora do contato)

I created a form in this style:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
  jQuery(document).ready(function(){
    jQuery('.contato_simula').submit(function(){
      var dados = jQuery( this ).serialize();

      jQuery.ajax({
        type: "POST",
        url: "http://simulador.consclic.com.br/simula",
        data: dados,
        success: function( data )
        {
          alert("deu certo");
        }
      });

      return false;
    });
  });
</script>
<form name="contato_simula" id="contato_carro" class="contato_simula" method="POST">
  <input type="text" class="amount" name="TxtValor_min" />

  <input type="text" placeholder="Nome *" name="TxtNome">

  <input type="text" placeholder="Cidade *" >

  <input type="text" placeholder="Telefone (com DDD)" name="txtTelefone">

  <input type="text" placeholder="E-mail *" name="TxtEmail">

  <input type="text" placeholder="CEP (indicaremos o corretor mais próximo de você)">

  <input type="hidden" name="modocalculo" value="credito">
  <input type="hidden" name="txtContato" value="1">
  <input type="hidden" name="rdMomento" value="agd">
  <input type="submit" value="Quero minha simulação">  
</form>

is at the url of ajax that I should put the link even? if I enter the link it appears error that gives, I must change something of zend?

1 answer

0

Voce should point the ajax url to a route, and process the data in the controller and make the call via http client

Zend_1

            $client = new Zend_Http_Client();
            $client->setMethod('GET');
            $client->setUri($url);

            $response = $client->request();
            $body     = $response->getBody();

if zend 2, 3 or expressive use lib https://framework.zend.com/manual/2.2/en/modules/zend.http.client.html, install via Composer.

use Zend\Http\Client;

$client = new Client();
$client->setUri('http://www.example.com');
$client->setMethod('POST');
$client->setParameterPost(array(
   'foo' => 'bar'
));

$response = $client->send();

if ($response->isSuccess()) {
    // the POST was successful
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.