是 form enctype “application/json"可用的? [英] is form enctype "application/json" available?

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

问题描述

我正在阅读有关使用 html 表单发布 JSON 数据的w3c 文档,并尝试对其进行测试.

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.

要跟踪功能的实际可用性,您需要查看 3rd 方资源,例如 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-enctypehttp://caniuse.com.

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.

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

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