Submit a form in the background

How can I submit a form to a third-party website without reloading the page (i.e. in the background)?

For some background, I am trying to programmatically register a user in my google account in the background.

I can programmatically register them using the following:

var div = document.createElement("div"); div.innerHTML = FORM_HTML; var form = div.getElementsByTagName("form")[0]; form.action = "https://www.google.com/accounts/ServiceLoginAuth"; form.GALX.value = FORM_GALX; // dynamically obtained using AJAX form.Email.value = USER_EMAIL; form.Passwd.value = USER_PASSWORD; form.submit(); 

This brings me to the system and opens the Google toolbar. How can I prevent form.action redirecting me?

Note that this div is never added to the document, which is preferable but not required.

+6
source share
3 answers

you can set a goal to submit the form in iframe
like this

 <form target="transFrame" method="POST" action="http://...." ></form> <iframe style="" name="transFrame" id="transFrame"></iframe> 
+11
source

You need to use AJAX to generate XMLHttpRequest in the best way, using any popular JS library like jQuery, Prototype JS or Mootools.

0
source

you can use ajax or jquery to query to submit the form in the background if you want to submit the form for a secure connection. I think they want to allow the submission of the form this way.

0
source

Source: https://habr.com/ru/post/893889/


All Articles