我在表达式引擎(1.6.8)模板中发布表单。我正在使用jQuery来做,但也尝试过HTML表单 - 结果相同。发布表单后,PHP超全局$ _POST为空,即使我的模板上已启用PHP(在包含处理模板上的表单和输出的模板的输入上),并且可以在Firebug中看到POST变量。
任何人都可以提出什么可能会导致此?
<html>
<head>
<script type="text/javascript" src="/_scripts/jquery-1.6.1.min.js"></script>
</head>
<body>
<form action="/select-locale/processing" method="POST">
<input type="text" name="test"/>
<input type="submit" name="submit" value="submit">
</form>
<a id="test" href="">link</a>
<script type="text/javascript">
$(function(){
$('#test').bind('click', function(e){
e.preventDefault();
var path = "/select-locale/processing"
var form = $('<form/>');
form.attr("method", "post");
form.attr("action", path);
var field = $('<input></input>');
field.attr("type", "hidden");
field.attr("name", 'locale');
field.attr("value", 'NZ');
form.append(field);
$('body').append(form);
form.submit();
});
});
</script>
</body>
</html>
服务器端代码(继承,而不是我自己):
<?php
var_dump($_POST);
var_dump($_GET);exit;
if (! isset($_POST['locale']))
{
$locale = FALSE;
$returnPage = "/";
}
else
{
$locale = $_POST['locale'];
$returnPage = $_POST['returnPage'];
}
if (isset($_GET['locale'])) {
$locale = $_GET['locale'];
$returnPage = "/";
?>
{exp:cookie_plus:set name="cklocale" value="<?php echo $locale;?>" seconds="2678400"}
{exp:session_variables:set name="userLocale" value="<?php echo $locale;?>"} <?php
}
?>
{exp:cookie_plus:set name="cklocale" value="<?php echo $locale;?>" seconds="2678400"}
{exp:session_variables:set name="userLocale" value="<?php echo $locale;?>"}
{exp:session_variables:get name="testSession"}
{if '{exp:session_variables:get name="testSession"}'=='yes' }
{redirect="<?php echo $returnPage;?>"}
{if:else}
{redirect="/nocookies/"}
{/if}
不知道,好像形式是越来越提交两次,因为jquery函数中的表单标签或誓言值的任一操作属性 – 2012-03-02 10:47:31
誓约值是什么? – codecowboy 2012-03-02 10:58:05
其授权密钥要求进行识别,一般追加在url – 2012-03-02 10:59:08