格式为"application/json"可用的? [英] is form enctype "application/json" available?

查看:115
本文介绍了格式为"application/json"可用的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 w3c文档关于以html格式发布JSON数据,然后尝试对其进行测试.

I was reading this w3c document about post JSON data with html form, and trying to test it.

我的测试表格如下:

 <form action="postjson.php" method="POST" enctype="application/json">
    <input type="hidden" name="touser" value="shenkwen" />
    <input type="hidden" name="msgtype" value="text" />
    <input type="hidden" name="agentid" value="23" />
    <input type="hidden" name="text[content]" value="test message" />
    <input type='submit' value="submit" />
  </form>

postjson.php

<?php var_dump($_POST); 

我期望$ _POST的值是一个JSON字符串,但是,它只是一个普通的PHP对象:

I was expecting the value of $_POST being a JSON string, however, it is just a normal PHP object:

array(4) { ["touser"]=> string(8) "shenkwen" ["msgtype"]=> string(4) "text" ["agentid"]=> string(2) "23" ["text"]=> array(1) { ["content"]=> string(33) "test message" } }

我尝试删除enctype属性,并且输出完全相同.然后,我返回到文档页面,发现其中显示了一些说明此标准可能无效的内容.

I tried removing the enctype attribute and the output is exactly the same. Then I went back to the document page and noticed that it says something indicating this standard may not be in effect.

所以这也是有关如何使用W3C网站的问题,在我看来,其中的某些页面只是草稿.那么,该页面是草稿吗?当我在w3c上阅读网页时,如何分辨它是草案还是工作标准?最后也是最重要的是,enctype='application/json'是否有效?

So this is also a question about how to use W3C website, it seems to me some pages on it are just drafts. So is this page a draft? When I read pages on w3c how do I tell whether it is a draft or it is a working standard? And finally and most importantly, is enctype='application/json' working or not?

推荐答案

W3C发布了许多草稿和建议,然后在整个社区中进行讨论.如果草稿已达到通常认为有用的阶段,浏览器供应商将/可能会开始实施它.然后,草案通常会进入推荐"阶段,这意味着W3C正式建议浏览器按照规定实施该技术.但是他们当然不能扭曲任何人的手臂.

The W3C publishes many drafts and proposals which are then discussed within the community at large. If a draft makes it to the stage where it's generally considered useful, browser vendors will/may start implementing it. The draft then typically advances to a "recommendation" stage, meaning the W3C officially recommends that browsers implement the technology as specified; but of course they can't twist anyone's arm to actually do so.

每个文档的顶部都会显示当前状态,并且 http://www.w3.org /TR/列出所有当前文档及其状态.您选择的那个广告在该页面上被列为过时"和已退休",并且在其顶部有一个巨大的标语:

Each document will say at its top what its current status is, and http://www.w3.org/TR/ lists all current documents and their status. The one you picked is listed as "obsolete" and "retired" on that page and has a ginormous banner at its top saying:

当心.该规范不再处于主动维护状态,HTML工作组也无意进一步维护它.

Beware. This specification is no longer in active maintenance and the HTML Working Group does not intend to maintain it further.

所以,不,当前可能没有浏览器在实现它.

So, no, probably no browser is currently implementing it.

要跟踪功能的实际可用性,您需要查看第三方资源,例如

To track the real-world availability of a feature you need to look to 3rd party resources like https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-enctype and http://caniuse.com.

这篇关于格式为"application/json"可用的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆