Jquery 如何通过重定向传递POST参数

Jquery 如何通过重定向传递POST参数,jquery,redirect,Jquery,Redirect,我有一个简单的链接,我想在“位置”中传递参数数据 我删除了重定向,我可以在控制台中看到参数(数据发布)已经传递,但是如果我在控制台中重定向,我什么也没有收到 // Search Reg $('.search_reg').click(function(){ var test = "test"; $.ajax({ type: 'POST', url: 'catalogue_search.php', dat

我有一个简单的链接,我想在“位置”中传递参数数据

我删除了重定向,我可以在控制台中看到参数(数据发布)已经传递,但是如果我在控制台中重定向,我什么也没有收到

// Search Reg
$('.search_reg').click(function(){
var test = "test";
            $.ajax({
            type: 'POST',
            url: 'catalogue_search.php',
            data: {'test': test},
            success: function (data) {
        var url = "catalogue_search.php";
            $(location).attr('href',url);
            }
           });
});
这有用吗

success : function () { window.location = "catalogue_search.php"; }

如果您对以下内容满意,请使用jquery:

html:

<a href="#" class="search_reg" value="the value i want to send by post">click here</a>
    <script>
        $(function() {
            $("<form id='myform' action='catalogue_search.php' method='post'><input type='hidden' id='test' name='test' value=''/></form>").appendTo("body");
            $('.search_reg').on('click',function() {
                var value= $(this).attr("value");
                $("#test").val(value);
                $("#myform").submit();
            });
        });
    </script>

jquery:

<a href="#" class="search_reg" value="the value i want to send by post">click here</a>
    <script>
        $(function() {
            $("<form id='myform' action='catalogue_search.php' method='post'><input type='hidden' id='test' name='test' value=''/></form>").appendTo("body");
            $('.search_reg').on('click',function() {
                var value= $(this).attr("value");
                $("#test").val(value);
                $("#myform").submit();
            });
        });
    </script>

$(函数(){
$(“”)。附件(“正文”);
$('.search_reg')。在('单击',函数()上){
var value=$(this.attr(“value”);
$(“#测试”).val(值);
$(“#我的表格”).submit();
});
});
更新: 您甚至可以在click事件的下面一行。由你决定

$("<form id='myform' action='catalogue_search.php' method='post'><input type='hidden' id='test' name='test' value=''/></form>").appendTo("body");
$(“”)。附加到(“正文”);

如果发送两个单独的查询,只有first-on(通过ajax)将返回包含数据的POST数组。第二个不会显示任何内容,因为您没有发送任何内容。
对我来说,最好的方法是添加隐藏表单并提交它(最好使用原生提交按钮)。或者你可以试试@susheel的方法,但对我来说有点奇怪。

我不想使用提交按钮或其他什么东西。你想实现$(location.attr('href',url);这行代码在那里做什么..当您使用ajax时。。。为什么要重定向??您已经需要单击,为什么不让单击提交表单,然后表单指向的act页面进行重定向?这是处理此类功能的正常方式。如果涉及重定向,那么进行回发比ajax要好。甚至他的要求也很奇怪:P:P