Submit to external site and submit site with redirect to another page

I need to submit a page to an external website. Not a problem.

The problem is the external website is displaying a successful message and not a good one, I need the site it was sent to redirect to something more user-friendly. The external website won't redirect, which I think might be the easiest if I pass it a redirect page.

Anyway, any suggestions for a simple and less laborious approach to this? I read about iFRAME. Is there another way?

Thanks in advance!

These are static HTML pages.

0


a source to share


3 answers


I am assuming that you cannot touch the markup of the external site.

If they are static then you are missing solutions. I've used the cURL library a lot to provide this kind of functionality (posting to an external site behind the scenes).



You might be able to do this with an iframe and JavaScript. Set the form target to be named iframe (maybe hide the iframe with CSS). Then he must file a fine.

+1


a source


Since you say "the external site is not being redirected", I am assuming that you have no control over it.

This means that you have three possible approaches that I can think of.



  • Proxy the request through your own server. This is a safe option, but will not use the cookies that the third party site expects from the user.
  • Use an iframe and assume it never fails (because you can't read the result). This could result in an error or timeout without compensation.
  • Use a Java applet (or similar) and ask the user to accept a series of dire security warnings (if they even have a Java plugin)
+1


a source


The IFRAME solution seems to be the simplest, but when an error occurs, you might not notice.

If the site that submits to receive predictable markup, then the AJAX route is preferred as it allows your site to parse and react to the publication results. However, it is vulnerable to a user who has JavaScript disabled.

Probably the best solution is to write your markup to use the IFRAME technique, but put an 'onsubmit' handler on the form. If JavaScript is enabled then the handler can use the AJAX stuff - otherwise the IFRAME wise exit will fire.

Remember to add 'return false' to the onsubmit attribute to prevent the IFRAME from being sent when JavaScript is enabled.

<form action="http://external.server/submission.html" 
      target="id_of_your_IFRAME" 
      onsubmit="submitViaAJAX(); return false">
    ... form fields ...
</form>

      

-1


a source







All Articles