Ajax的数据发送问题

I am having trouble to solve a simple ajax function

I want to send php variables with ajax to another page if the user click on a link

Javascript

function sendData(a, b, c, d)
{
    $.ajax({
            url: "page.php",
            type: "POST",
            data: {"a": a, "b": b, "c": c, "d": d},
            success:function(data) {
                console.log(data);
                document.location.href="page.php"; 
            },
            error:function(jqXHR,error_string,error){
                console.log(error);
            }
        });
}
<button  onClick="sendData(<?php echo $a ?>, <?php echo $b ?>, <?php echo $c ?>, <?php echo $d ?>)"> click </button>
查看全部
weixin_33698823
weixin_33698823
2017/06/28 00:39
  • php
  • ajax
  • javascript
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

2个回复