日期:2014-05-16  浏览次数:20326 次

请教一个jquery弹出对话框确认后跳转并post参数到另个页面的方法
本帖最后由 ShunYea 于 2013-01-06 17:16:30 编辑
如题请教,新人学写PHP,想在某个页面点击一个按钮后,弹出个窗口询问是否确认,确认后跳转到另个页面,并同时将参数传出去,要用post的方法将参数传到那个页面。

现在参数是一个span的标签,用js方法现在已经能够取得值并在弹出的对话框里显示,但是点击确认后的操作代码就不会写了,请教。

同时想问下,传过来的这个页面,post方法应该比较安全吧?否则有没有可能直接访问这个页面而带个参数,结果值就变成自己带的这个参数?

谢谢解答。

这个是我自己写的:


function get_lastmonth()
{
var getabc = document.getElementById("lastmonth").innerHTML;
if(confirm("确认操作 "+getabc+" 吗?"))
{

$.ajax({
type: "POST",
dataType:"json",
url: "action.php",
data: "do=apply&getabc="+getabc,
});
location.href="action.php";
} else {
return;
}
}


这个代码跳转过去那边获不得任何参数……

------解决方案--------------------
<script>
function get_lastmonth()
{
    var getabc = document.getElementById("lastmonth").innerHTML;
    if(confirm("确认操作 "+getabc+" 吗?"))
    {
      document.getElementById("test").value=getabc;
        return true;
    } else {
        return false;
    }
}
</script>
<form action='action.php' method='post' onsubmit="return get_lastmonth()">
<span id='lastmonth'>20130106</span><br>
<input type='hidden' id='test' name='test'>
<input type='submit'>
</form>