【发布时间】:2015-05-19 20:44:11
【问题描述】:
php 我有以下代码
<form id="one" method="POST" action="#">
<input type="text" name="rfc" />
<button type="submit" name="selection" value="1">Option 1 </button>
<button type="submit" name="selection" value="2">Option 2 </button>
<input type="submit" name="selection" value="4" />
</form>
<section id="new_section"></section>
<script>
$('#one').submit(function(event){
var data = $(this).serialize();
$.post('two.php', data)
.success(function(result){
$('#new_section').html(result);
})
.error(function(){
console.log('Error loading page');
})
return false;
});
</script>
在 two.php 中,我验证了 rfc 和选择字段的值
两个.php
print_r($_POST);
而 print_r 只显示 rfc 而不是 selection ,输出如下:
数组([rfc] => WIRK510828)
发生这种情况是因为 action=# 吗?
【问题讨论】:
-
我认为您应该将按钮更改为提交类型的输入。
-
这两个
<button>标签是干什么用的?