1

I am trying to simulate a post request by creating form elements on the fly and then using the submit() function. I don't know how to capture the response from the server for the post request. I am making a cross domain post request.

Anything after the submit() call does not get executed. How can i capture the response to the submit() call? What is the return value of the submit() function? Any link to the api documentation would be appreciated.

Mukesh Soni
  • 6,646
  • 3
  • 30
  • 37

2 Answers2

1

submit() stops all execution on the current page while it waits for a new page to be sent from the server.

If you want to do something AFTER submit(), you should consider using AJAX-based techniques.

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
1

The script stops execution because the browser exits the page once the form is submitted (in order to go to the form's "action" page). The ways to do something after the form is submitted is to do the response logic on the form's action page or using AJAX to keep on the page once the server has responded.

André Leria
  • 392
  • 3
  • 17