I need to create a POST
request with $.ajax
that would be the equivalent of submitting the following form:
<form method="POST" action="test">
<input name="foo" value="1">
<input name="bar" value="2">
<input name="foo" value="3">
<input name="bar" value="4">
</form>
In particular, I have values with same names, which need to be passed in the correct (possibly interleaving) order, so in the case of a GET
request foo=1&bar=2&foo=3&bar=3
would be correct and foo=1&foo=3&bar=2&bar=3
would be incorrect.
I looked into the traditional
setting, but I haven't managed to construct the data
parameter correctly.
Currently, I am using jquery_form
for such use cases, but I did not find any way to cancel the requests send by this and it still needs a form
, which I sometimes create dynamically and remove it later again.
Is there a better way that creating the fully encoded body of the request manually? Maybe there is even a solution for requests that need multipart/form-data
encoding without having to do the encoding manually?