1

I need to submit a form and include some custom http headers with the request (the API requires them).

Something like jQuery.ajax() works great (https://api.jquery.com/jQuery.ajax/), I can use the beforeSend arg to compose some headers.

However I need this for a synchronous request, to direct the browser to the destination of the form. So one of the following two would work, but I'm not sure if a solution exists.

  1. Have JS create and submit a form. How do I include custom http headers in a form?

  2. Find an equivalent function to jQuery.ajax(), that will submit a synchronous request.

1 Answer 1

1

jQuery.ajax has a property async which can be set to true or false.

async false would make it a synchronous request.

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

1 Comment

Sorry I should have clarified - needed it to be synchronous and take the user to that page in the same window, like the behavior of a regular form. I'll edit the question to clarify.

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.