是形式enctype“appication / json”可用? [英] is form enctype "appication/json" available?

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

问题描述

我正在阅读这篇 w3c文档,内容涉及使用html表单发布JSON数据,并试图进行测试。



我的测试表格如下:

 < form action =postjson.phpmethod =POSTenctype =application / json> 
< input type =hiddenname =touservalue =shenkwen/>
< input type =hiddenname =msgtypevalue =text/>
< input type =hiddenname =agentidvalue =23/>
< input type =hiddenname =text [content]value =test message/>
< input type ='submit'value =submit/>
< / form>

postjson.php

 <?php var_dump($ _ POST); 

我期待$ _POST是一个JSON字符串,但它只是一个普通的PHP object:

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

我尝试删除 enctype 属性与输出完全相同。然后我回到了文档页面,注意到它表示这个标准可能没有生效。



所以这也是一个关于如何使用W3C网站的问题,在我看来一些页面只是草稿。那么这个页面是一个草稿?当我阅读w3c的页面时,我该如何判断它是草稿还是工作标准?最后也是最重要的是,是不是工作或者不工作?

解决方案 enctype ='application / json' / W3> W3C发布了许多草案和提案,然后在整个社区内进行讨论。如果草稿使其进入普遍认为有用的阶段,浏览器供应商将会/可能开始实施它。然后草案通常进入推荐阶段,这意味着W3C正式建议浏览器按照规定实施技术;但它们当然不能扭曲任何人的手臂来实际做到这一点。



每个文档都会在其顶部显示其当前状态, http://www.w3.org/TR/ 列出了所有当前文件及其状态。您选择的那个在该页面被列为过时和退休,并且在其顶部具有巨大的横幅说:


当心。此规范不再处于主动维护状态,HTML工作组不打算进一步维护它。


所以,不,可能不是浏览器目前正在实现它。



要跟踪功能的真实可用性,您需要查看第三方资源,如 https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element / form#attr-enctype http://caniuse.com


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

my test form is as follows:

 <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>

and content for postjson.php

<?php var_dump($_POST); 

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" } }

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.

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?

解决方案

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.

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:

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.

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

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