1

Here is my form on domain1:

<form id ='myForm' action='domain2' method='GET' target='_top'>
<input type='hidden' name='id' value='00345897'>
<input type='hidden' name='status' value='Success'>
<input type="submit" value="Submit">
</form>

Now when I submit my form it goes to the domain2 as mentioned in the action. Is it possible to get the response back to domain1? I am getting the response if the target attribute is '_self' or if I remove the target attribute. But with target='_top' the page is redirected to domain2. How can I get the response back to domain1? Thanks.

Egon Allison
  • 1,329
  • 1
  • 13
  • 22

1 Answers1

1

The response can't go anywhere other than to the browser making the response.

If you don't specify a target, then it will appear in the same window or frame as the page with the form on it (replacing the page with the form on it).

If you specify target="_top" then it will appear in the top-level frame replacing that.

If you want to get the data to the site making the request then you need to either:

  • Make the HTTP request from domain1's server and not from a browser or
  • Use Ajax to make the request to domain1 (dealing with cross origin issues) and then use JavaScript to send the data to domain1.
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Thanks for the reply, but in my case this form is dynamically generated, so doing ajax call is not possible from domain1. You mentioned that the response will appear in the top level frame, now can i get this response back to the domain1 using javascript? I tried with parent.psotMessage but that didn't work. – Bhargav Madia Mar 11 '19 at 07:12