I\'d like to send some data using an XMLHttpRequest in JavaScript.
Say I have the following form in HTML:
<
FormData
to submit an AJAX request
This does not fully answer the OP question because it requires the user to click in order to submit the request. But this may be useful to people searching for this kind of simple solution.
This example is very simple and does not support the GET
method. If you are interesting by more sophisticated examples, please have a look at the excellent MDN documentation. See also similar answer about XMLHttpRequest to Post HTML Form.
Limitation of this solution: As pointed out by Justin Blank and Thomas Munk (see their comments), FormData
is not supported by IE9 and lower, and default browser on Android 2.3.