Niick Mosqow
Niick Mosqow

Reputation: 21

JavaScripts: Cloaking redirect for posting data

I have a poll system provided by an outsourced application.

After users choose one of the radio button's choices and click a Submit button, my JavaScripts will redirect them to a specific url (ex. http://www.poll.com/answer). This is a must for posting data to that outsourced application, so this url must be processed.

But what if I don't want to show users this page, but redirect them to a finish page, What should I do with this condition in JavaScripts?

It looks like this.

..When click Submit..

  1. Hidden Run URL for posting data to an outsourced application. (MUST DO)
  2. Redirect to MY finish page.

Upvotes: 0

Views: 139

Answers (2)

Akshay
Akshay

Reputation: 3198

I'm going to make a few assumptions to clarify my understanding.

  1. You have a web page which contains radio buttons
  2. When a user selects a radio button and submits, you want to post this answer to an external url
  3. Once the data is posted to the external link, you want to show a success page to the user.

You have two options:

Server Side

  1. When a user submits a radio button selection, post the data to a url on your own server. Like a simple form submit
  2. On the server, take the user's input and post it to the target URL.
  3. Return a success page to the user

As far as the user is concerned, he never leaves your site.

Client Side - Ajax

  1. When a user submits a radio selection, trap the submit event, make an ajax call to the target url, posting the user's selection
  2. When the ajax call returns success, ie the data has been posted properly, redirect the user to a success page url, hosted on your own server

Let me know if you need further clarification.

Upvotes: 1

RacerNerd
RacerNerd

Reputation: 1579

One possible solution, depending on if you are doing server side programming, is to submit the data in the code behind.

After submitting the data to your code that handles the form submission. Your code passes the values to the third party instead of having the third party be the form submission location. Since you are handling the form submission with your code, you are free to redirect the user as you please.

If you aren't doing server side programming, I'm not sure if there is a way to hide the form submission location from the user.

Upvotes: 1

Related Questions