This cannot be done for security reasons. If this were allowed than one web page could force your browser to post a request for a bank transfer to your bank making a guess that you are logged in with the bank.
You can only do it via ajax as in the PHP assuming the domain is the same. Massimo On Sunday, 5 July 2015 05:06:59 UTC-5, Sepehr Mohamadi wrote: > > Thanks a lot Anothony, > > First I should say yes, I need to recieve data first then redirect user to > the gateway. > > But, I tried your solutions but non of them worked. > > Because I need the user to redirect to gateway to enter some additional > info on Gateway site. > But in requests module don't redurict the user there, and just Post the > data to the gateway. > > Let me know if you have any idea. > > Thanks > > > On Saturday, July 4, 2015 at 7:56:32 PM UTC+4:30, Anthony wrote: >> >> You could return a 307 redirect response, which would instruct the >> browser to re-post the data to the new URL, but the browser will then >> likely prompt the user to confirm they want to re-post the data. This will >> likely be confusing to the user, so should probably be avoided. >> >> If you just need the data posted directly to the payment gateway, but you >> don't need it posted to your own server at all, then all you have to do is >> change the "action" attribute of the form to point to the appropriate >> external URL. If it is a web2py form, something like: >> >> form = FORM(..., _action=third_party_url) >> >> If you need to receive the data on your server first and then have it >> posted to the gateway, you would not use a redirect. Instead, just have the >> form post to web2py as usual, and in the controller, send the post request >> to the gateway using urllib2 or the requests library. web2py also includes >> the fetch() function in gluon.tools, which uses urllib2 -- if your data are >> in a dictionary, you would do: >> >> from gluon.tools import fetch >> result = fetch(external_url, data) >> >> You would want to check the result to make sure the post was successful. >> >> Anthony >> >> On Saturday, July 4, 2015 at 7:45:24 AM UTC-4, Sepehr Mohamadi wrote: >>> >>> Hi Everybody, >>> >>> I want to redirect navigation to an outside URL with a POST Method. >>> >>> I should send payment info to a payment gateway through a POST Method. >>> Then payment gateway again callback to web2py with results. >>> >>> I searched everywhere in the Internet, Web2py Book and this forum, but >>> could not find a clue! >>> >>> Please guide! >>> Thanks, >>> Sepehr >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

