0

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.
t.niese
  • 39,256
  • 9
  • 74
  • 101
  • Please elaborate what you mean by "posting data to an outsourced application". are you passing the selected radio button value or some param? You can easily use ajax here. – Akshay Jan 10 '14 at 01:57
  • In order to submit a poll result, the application requires me to run their URL like this >> www.poll.com/Answer. If it runs properly, the poll result will be accepted. However, to do this, my website will redirect user to the URL above, which is what I don't want. – Niick Mosqow Jan 10 '14 at 02:05

2 Answers2

1

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.

RacerNerd
  • 1,579
  • 1
  • 13
  • 31
1

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.

Akshay
  • 3,158
  • 24
  • 28
  • Thank you. Yes, the first method on server side is correctly what I'm thinking of. I just don't know how to code it properly. now I use if..else.. statement to detect which choice is checked. If it is checked, then submit that choice to the external URL. But I cannot hide that external page. – Niick Mosqow Jan 10 '14 at 02:19
  • You are misunderstanding, if you submit to the external url in the backend, why would the user ever see anything? Look at this http://stackoverflow.com/questions/4205980/java-sending-http-parameters-via-post-method-easily – Akshay Jan 10 '14 at 03:28
  • I'm assuming Java as the backend – Akshay Jan 10 '14 at 03:28
  • Thank you. because it does not work like a form submission. Please look at this scripts, this is how I do submit the result. if (document.getElementById('page1_q1_button1').checked) { window.location = "https://www.poll.com/answer_1"; } else if (document.getElementById('page1_q1_button2').checked) { window.location = "https://www.poll.com/answer_2"; } ... loop until button 6 – Niick Mosqow Jan 11 '14 at 01:57
  • Use ajax - the client side approach. – Akshay Jan 11 '14 at 02:03