Submit form data to url. Redirect user to another

I am needing to submit to submit html form data to a backend python script. While sending users to a thank you page. Here is the code I have now. This code does nothing. It does not submit the data or redirect the user

<div class=login-content container" style="max-width: 800px;">
<form role="form" id="form" name="form">
    <h2 class="form-signin-heading">{{ _("One Last Step") }}</h2>


    <input name="app_name"
        class="form-control" placeholder="{{ _('app_name') }}" required autofocus><br>

    <input name="admin_password"
        class="form-control" placeholder="{{ _('admin_password') }}" required><br>



        <input name="install_app"
        class="form-control" placeholder="{{ _('install_app') }}">

    <br>
    <button class="btn btn-primary btn-complete-signup" type="submit" >{{ _("Complete") }}</button>
</form>
</div>
    <script type="text/javascript">
    $(function() {
  $('form').submit(function(){
    $.post('http://website/api/method/python.script', function() {
      window.location.href = 'http://google.com';
    });
   return false;
  });
});
</script>

This data would not submit the data but would redirect users to website/google.com(example)

    <form role="form" method="POST"  onsubmit="window.location='google.com'"
            action="http://website/api/method/python.script?                usr=Administrator&pwd=Bear515515">
    		<h2 class="form-signin-heading">{{ _("One Last Step") }}</h2>

	
    		<input name="app_name"
    			class="form-control" placeholder="{{ _('app_name') }}" required autofocus><br>
	
    		<input name="admin_password"
    			class="form-control" placeholder="{{ _('admin_password') }}" required><br>
	

		
        		<input name="install_app"
        		class="form-control" placeholder="{{ _('install_app') }}">
		
        	<br>
    		<button class="btn btn-primary btn-complete-signup" type="submit" type="hidden" name="redirect"         value="website.com" >{{ _("Complete") }}</button>
    	</form>

Well, there’s a couple of different approaches off the top of my head, though i’m not sure why you wouldnt just have the python script spit out a thank you page itself.

1: Redirect flow
Have the form submit to the python script, which outputs a redirect signal to point the browser to the target landing page.

2: AJAX handling
Have the submit button fire an AJAX request at the python script; when it receives the done signal, send the user a location-change to load the thank you page.

3: AJAX without moving
As #2, but instead of sending a location-change, just display a popup or such within the existing page.

Can you tell me about option 1. I have never done anything like that in python. I am just wanting the user to be sent to www.example.com. What imports do you need.

It would be a question of making sure the http server was set up to handle CGI scripts, and then deploying the script to that location, importing the cgi package and using it to interface with the data. At that point, print statements are treated as html output to the user;

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.