【发布时间】:2015-09-16 05:57:43
【问题描述】:
我使用 Polymer 入门套件 1.0.2,并且我正在尝试根据我找到的(少量)文档使用铁型。
我的方法表单是“post”并且只包含一个输入。
我的表单“action”是一个 PHP 脚本 (add.php),显示 $_GET 和 $_POST 的内容:
print_r($_POST);
print_r($_GET);
我的表单组件(form_eclp.html)是:
<dom-module id="my-form">
<template>
<div class="horizontal center-center layout">
<div>
<div class="horizontal-section">
<form is="iron-form" id="formGet" method="post" action="add.php">
<paper-input name="name" label="Name" required></paper-input>
<br><br><br>
<paper-button raised onclick="clickHandler(event)">Submit</paper-button>
</form>
</div>
</div>
</div>
</template>
<script>
function clickHandler(event) {
Polymer.dom(event).localTarget.parentElement.submit();
}
Polymer({
is: 'my-form',
listeners: {
'iron-form-response': 'formResponse'
},
formResponse: function(e) {
// ?????????
}
});
</script>
</dom-module>
如果来自:
<link rel="import" href="form_eclp.html">
<my-form></my-form>
当我在名称输入中输入文本“test”后单击提交按钮时,我可以在浏览器开发人员工具的网络选项卡中看到这是一个 POST 请求,好的,但 url 是 add.php?name=测试,在响应选项卡中我有:
Array
(
)
Array
(
[name] => test
)
根据我的表单操作(add.php 脚本),第一个数组用于 $_POST,第二个用于 $_GET。
我可以看到,尽管 form method="post",但它是一个“get”请求,因为只填充了 $_GET,$_POST 中没有任何内容。
我不明白,这是一个错误吗?
【问题讨论】:
标签: php html forms http-post polymer-1.0