Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8371735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:14:07+00:00 2026-06-09T14:14:07+00:00

I currently have a form that is submitting data to an affiliate using the

  • 0

I currently have a form that is submitting data to an affiliate using the GET method. The problem is, when a user fills out the form they are redirected to that same URL as the GET action goes to, it is an api page of random code.

I need the user that fills out the form to be redirected to a thank you page that i host while the information from the form is still sent to that affiliate api page.

I cannot manipulate the affiliate api page. How do i go about doing this? I’ve heard different answers including POST, Iframe, ajax, onsubmit.

Can someone confirm which method will work the best and why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:14:08+00:00Added an answer on June 9, 2026 at 2:14 pm

    Edit After discussing things in chat, we came to the conclusion that server-side posting was a better way to go. Here is an example of implementation:

    HTML:

    <form id="my_form">
    <!-- form elements -->
    </form>
    <div id="status_message"></div>
    

    Javascript:

    $('#my_form').on('submit', function (e){
        $.ajax({
          type: "POST",
          url: "localProxy.php",
          data: $('#my_form').serialize(),
          success: function (response) {
             // do something!
          },
          error: function () {
             // handle error
          }
        });
    });
    

    PHP (localProxy.php)

    $ch = curl_init(); 
    curl_setopt ($ch, CURLOPT_URL, 'http://thirdpartydomain.internet/login_url.php'); 
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
    curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); 
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $_POST);
    curl_setopt ($ch, CURLOPT_POST, 1);
    $result = curl_exec ($ch);
    curl_close($ch);
    
    // do something with the data on your end (if anything), or render the "thank you" page
    die('<h1>Thanks!</h1>');
    

    Original answer

    There are a couple of approaches.

    The first way, you mention (through the tag) that you have jQuery — in that case, you can use jquery’s ajax method to both post the data to the API and to post it to your own server to get the thank-you message.

    <form id="my_form">
    <!-- form elements -->
    </form>
    <div id="status_message"></div>
    

    … in your “ready” function:

    var API_URL = 'http://www.some-api-provider.com/api.php';
    var MY_URL = 'http://www.my-website.net/post_handler.php';
    $('#my_form').on('submit', function (e){
        e.preventDefault();
        var error = false;
    
        // validation here, if there is an error, set error = true;
    
        if (error == true) {
            alert('There was a problem!'); // do something better than this!
            return false;
        }
    
        $.ajax({
          type: 'GET',
          url: API_URL,
          data: $('my_form').serialize(),
          success: function () {
            $.ajax({
              type: 'POST',
              url: MY_URL,
              data: $('#my_form').serialize(),
              success: function (response) {
                $('status_message').html(response);
              },
              error: function () {
                alert('There was a problem!'); // do something better than this!
              }
            });
          },
          error: function () {
            alert('There was a problem!'); // do something better than this!
          }
        });
        return false;
    });
    

    What’s happening there? We use the on event to bind an event listener to the ‘submit’ event of the form. When the user clicks the Submit button, that listener code will be invoked.

    It, in its turn, will serialize your form’s data, then send it the API via GET. As long as that works, it will call the success function, which in turn will send the data to your server via POST. The div status_message will be updated with the result return from your server.

    The other approach is to post the data to your server normally, then use cURL or some other server-side HTTP connectivity to submit the data to the API. I might favor this method, as it is less dependent on javascript; if your user has scripts turned off, the javascript method will fail.

    Without knowing what server-side technology you’re using, I couldn’t give any example, but if you go that route and run into trouble, you can always ask another question!

    Documentation

    • jQuery.ajax() – http://api.jquery.com/jQuery.ajax/
    • jQuery.on() – http://api.jquery.com/on/
    • PHP curl – http://php.net/manual/en/book.curl.php
    • ASP.net WebRequest tutorial – http://msdn.microsoft.com/en-us/library/debx8sh9.aspx
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have form that checks if a user has unsubmitted changes when they
I currently have a html form submitting data to my database. The user submits
I currently have a simple form that when you click the save button will
I currently have a PHP form that uses AJAX to connect to MySQL and
I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down
I currently have this useful code that I found elsewhere on StackOverflow: form.DrawToBitmap(bmp, new
I currently have a form with inputs and name attributes. I'm able to get
I have a form in my MVC application that in theory should submit data
So, I have a form on the page that I was using an input
Currently I have a small form that uses a asp:linkbutton to submit and send

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.