Get JSON data on HTML Form Submit with HTTP POST
I am trying to get JSON data on click of a button
Heres the HTML for it
<html>
<title> </title>
<body>
<h2> Main API - http://api.kalendern.se/api</h3>
<form method="get" enctype="application/json; charset=utf-8"
action="http://api.example.com" border="1">
<input type=submit value="Show Main API"> </td>
</form>
<开发者_高级运维;/body>
</html>
I am getting XML data.
However I need JSON data. How can I achieve this?
Is the enctype I am setting same as the content-type?
If not what is the difference and what is the right value to get the JSON data?
Thanks
Dev.
However I need JSON data. How can I achieve this?
To get it directly, it depends on the service. The URL to the documentation you provided leads to a 404.
To get it indirectly, you could run a server side process to fetch the XML and convert it to JSON, then talk to your server side process instead of the remote API. Likewise, you could use a third party service that can do that (YQL will, I think).
Is the enctype I am setting same as the content-type?
More or less … but of the data the browser sends. Only the values "application/x-www-form-urlencoded" and "multipart/form-data" are well supported.
精彩评论