如何在点击另一个页面中的按钮时加载另一个页面,并在jquery中传递值给加载的页面


how to load another page when clicking a button in another page and pass values to the loaded page in jquery?

页面中有一个按钮。在点击按钮,它应该去另一个页面,该页面应该被查看。此外,我想传递一些值到第二页时,按钮被单击,并在第二页中显示传递的值。

我写了一个代码在ajax,但它不工作。

<script>
$(document).ready(function(){
$(".chk").click(function(){
if($('input.checkin:checked').val()){

         var apikey = '60CF3C2oh7D+Q+aHDoHt88aEdfdflIjFZdlmsgApfpvg8GXu+W8qr7bKM33cM3';
         var password = 'fHdfvxk';
         var endpoint = 1;
         var method = 'ProcessPayment';
         var dataString = 'APIKey='+apikey+'&APIPassword='+password+'&ddlSandbox='+endpoint+'&ddlMethod='+endpoint;

          $.ajax({

                type: "POST",
                url: "responsive.php",
                data: dataString,
                cache: false,
                success: function(result){


                }
        });

    //window.location.href= 'http://localhost/m/responsive.php';
    }
    else{
        alert("Please Accept the terms and conditions and continue further!!!!");
    }


}); });
</script>

我写了一个代码在ajx当按钮单击,但它只会传递值到该页。但是页面无法查看。有谁能提出一个解决方案吗?

您可以重定向到页面,而不是使用ajax。

<script>
    $(document).ready(function(){
    $(".chk").click(function(){
    if($('input.checkin:checked').val()){

             var apikey = '60CF3C2oh7D+Q+aHDoHt88aEdfdflIjFZdlmsgApfpvg8GXu+W8qr7bKM33cM3';
             var password = 'fHdfvxk';
             var endpoint = 1;
             var method = 'ProcessPayment';
             //var dataString = 'APIKey='+apikey+'&APIPassword='+password+'&ddlSandbox='+endpoint+'&ddlMethod='+endpoint;
            // use  location href instead of ajax 
             window.location.href = "responsive.php?APIKey='+apikey+'&APIPassword='+password+'&ddlSandbox='+endpoint+'&ddlMethod='+endpoint;
        }
        else{
            alert("Please Accept the terms and conditions and continue further!!!!");
        }
    });
 });
    </script>