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.

4
  • 2
    There is no return value. If you want to get values back from the server, use Ajax. Commented May 31, 2012 at 19:47
  • Ajax fails since cross domain requests are not allowed. Commented May 31, 2012 at 19:48
  • You never said you were doing this cross-domain. In that case, what exactly are you trying to do? Commented May 31, 2012 at 19:50
  • 1
    Possible duplicate of stackoverflow.com/questions/298745/…. Commented May 31, 2012 at 20:17

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Trying with ajax gives me this error - "Origin null is not allowed by Access-Control-Allow-Origin."
That's correct. You cannot use a browser to interact with an external site that way. You did not state this requirement in your question.
edited my question. Sorry for the misunderstanding. So i guess i will have to go php/curl way.
seems the current browsers do allow cross domain ajax requests (with caveats) - bennadel.com/blog/…
They do, but that requires the cooperation of the third-party site.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.