0

I am attempting to submit a POST request to a server that requires the data to be formatted using JSON. Here is my code:

<form action='myurl.com' method='post' enctype='application/json'>
    <input name='name' value='Bob' >
    <input name="pet[type]" value='dog'>
    <input name="pet[name]" value='buster'>
    <input type="submit" value="Submit">
</form>

When I submit, I get the response that it is not formatted in JSON. Is that not what enctype='application/json' does or am I misunderstanding it? How do I format it using JSON?

Thanks

smidgey
  • 11
  • 1
    *"Work was being done on adding `application/json`, but that has been abandoned."*: https://stackoverflow.com/questions/4526273/what-does-enctype-multipart-form-data-mean – Felix Kling Dec 12 '16 at 19:53
  • You need to use XMLHttpRequest or fetch to generate a JSON encoded POST request from a browser. – Quentin Dec 12 '16 at 19:57

0 Answers0