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..
Hidden Run URL for posting data to an outsourced application. (MUST DO)
Redirect to MY finish page.
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.
I'm going to make a few assumptions to clarify my understanding.
You have a web page which contains radio buttons
When a user selects a radio button and submits, you want to post this answer to an external url
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
When a user submits a radio button selection, post the data to a url on your own server. Like a simple form submit
On the server, take the user's input and post it to the target URL.
Return a success page to the user
As far as the user is concerned, he never leaves your site.
Client Side - Ajax
When a user submits a radio selection, trap the submit event, make an ajax call to the target url, posting the user's selection
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.
Related
I am using javascript and Node JS to build a website to collect data for my writing research. The website is designed with a series of webpages with each page housing a different typing or writing task. Participants need to complete a task on one page, click the submit button to post the data to the server side, and click next to move on to the next page until they reach the last page of the study. For your information, here is the website I created: https://writingresearch.herokuapp.com.
However, here comes one issue: in some cases, when the internet connection on the client side is weak or unstable, it might take some time (say, more than 2 seconds) for the data to reach the server side for processing. In other words, the participant of the study may go to the next page before their posted data are successfully processed on the server side. If this happens, the server side ends up losing the data.
Thus, I am wondering if there is a method to enable the communication between the server side and the client side so that the user of the website cannot go to the next page until their post request is successfully processed. Does anyone know how to do this in Node JS? I hope I have explained my question clearly.
Thanks for your time and attention. I really appreciate your help!!!
On pressing the submit button, you should do the following:
Disable the "Submit" button so that user doesn't send another POST request again by clicking on submit button again. Show a loader somewhere so that user could know that answer is being submitted.
Disable the "Next" button until you receive a successful response from server.
On receiving successful response from server, enable both buttons and show a notification (such as an alert box) informing that the answer is submitted successfully.
If you receive error from server, then also show the error in the notification (or in the alert box) and enable both buttons.
Page A is the parent. From page A, the user clicks on a link and a new page B opens. I do not own page B. Then there, there is some kind of registration form for the user to complete. I need to know in page A that the form on B is submitted correctly when it happens (inject JS?).
I will handle the JS to determine if the form is completed or not. What I'm asking if it is possible what I am looking for, to send back the info to page. I would do this using an iframe, all within the same page but I am getting mixed content errors as page B is in http (I need my page A to be in https).
Normally this is not possible, but sometimes forms have some kind of callback, for instance forms from payment providers. They allow you to send your customer to their payment page, and they redirect them back to a callback page after the payment is done. Hopefully PageB supports such a thing, otherwise, you're in trouble.
One possible solution, if the form isn't very complex, and doesn't have much scripting, and doesn't require logon or other session or cookie related stuff, you might use file_get_contents or curl to get the form, modify it a little to post the changes to another script of yours, and then, from the server, post the form data to originating server. That way, you capture the entire form and everything the user submits is submitted through your server, giving you all the information you need.
Of course this is not easily possible with every form, so you'll have to try if it works for this one.
I just learned how to make HTTP requests via POST to a URL. Now, the website that I need to make a POST request to sends you the page without the form and when you click a button it loads the form with JavaScript.
I tried to find the form on the page, but it does not exist.
Is it only possible to fill the form in the main page after that the form has been loaded with JavaScript? How can I fill out the form?
I tried to use the normal POST method, but not working.
We have a complex form that we created as a PDF. We want users to be able fill out the PDF and then either print it out and mail it in or click a Submit button and have it emailed to the client. What's the best way to do this?
I understand that we can attach javascript to the Submit button on the form. I'm thinking we could use Javascript to submit the form to the website and then write a REST type page that would handle emailing the PDF to the appropriate place. We are using ASP.NET/DotNetNuke on the backend of the site.
Dave,
You have a few options on this but a lot of it is going to be depending on how you want the user to handle input.
If you want the user to fill the ACTUAL PDF themselves, then you have a lot less control. But it can submit to a location and go from there, but saving it as a modified filled PDF requires either licensing for the document, OR for the users to have the full version of acrobat.
Another option is for you to build an input form for the user, then fill the PDF and commit the information, then either send them the file if they want to print or e-mail it off yourself.
I've done both in the past for previous clients/jobs. Feel free to ping me directly with a bit more detail if this doesn't help.
Edit - More detail based on comment
In this situation you have a few options.
Actually it looks like you can get to part of this now via the PDF create process - http://help.adobe.com/en_US/Acrobat/9.0/Standard/WS58a04a822e3e50102bd615109794195ff-7e0d.w.html
From a server side sending you have a few options. They can save it and upload it, which isn't best.
You can have a form post action, this will submit their answers to your server, you could then plug them into a PDF, save it, then forward it on
In the end it will depend on the true workflow.
Have you considered this SaaS? http://www.pdfescape.com/what/publishing/
I went to test my page on another browser. On google chrome i can fill out a form, hit back and forward and still have the data there. Now i need to refresh the page so certain data is correct (such as session id if the cookie expires or user logs out before submitting). I refresh and lose all data. Is there some option i can set so all data is kept?
What framework are you using? For example, ASP.Net WebForms would handle this via ViewState (yuck), ASP.Net MVC would require you to do this manually etc.
You essentially need to persist your data somewhere while the page reloads, and then re-populate the controls.
You would have to send the values to the server while they are typed in, and then repopulate the form fields on refresh.
Yes, the only secure way to do this is to use a serverside script to store the form temporarly. Since browsers handles back/forward diffrently your page won't be x-browser compatible if you don't use the server. If the user hits the back button you are kind of lost already since no post is done, unless you post the form with some javascript magic before the new page is refreshed.