onClick将'POST'数据发送到php文件并获得结果

时间:2017-09-15 15:21:18

标签: javascript php jquery

const columns = [
  userColumn({
    key: "id",
    render(id: number) {
      return id;
    }
  }), // ok, inferred as Column<User,"id">
  userColumn({
    key: "name",
    render(name: string) {
      return name;
    }
  }), // ok, inferred as Column<User,"name">
  userColumn({
    key: "id",
    render(id: string) {
      return id;
    }
  }) // error as expected
];

以上代码无效

  

我想从此页面发送表单数据,此页面接收表单数据   在$ _POST变量中我现在想要有人点击重新发送代码   然后jquery运行并将此表单数据发送到另一个php页面并获取   该页面的结果。

3 个答案:

答案 0 :(得分:1)

你在onclick函数声明中缺少括号:

$("#vE_rebtn").click(function(){
// add this: ----------------^^

您的浏览器控制台应该告诉您当前代码的语法无效。

除此之外,此代码应该可以在单击$_SESSION["verifyEmIPv"]时将<div id="vE_rebtn">的值发送到服务器。

答案 1 :(得分:1)

试试这个。我认为这将是有效的

    <script>
    $(document).ready(function(){
        $("#vE_rebtn").on("click",function(){
        var reverifyEmail = $("#verifyEmIPv").val();
            alert(reverifyEmail);
        $('#rE_rebtn').hide();
        $('#re_verifyEMAIL-notice').hide();
        $('#rE_resending').show();
        $.ajax({
            type: 'POST',
            url: 'data/system/auth.php',
            data: {verifyEMAIL: reverifyEmail},
            success: function (data) {
                console.log(data);
                $('#verifyEMAIL_notice').hide();
                $('#re_verifyEMAIL_notice').show();
            }
        });
        });
    });
</script>
<input type="hidden" id="verifyEmIPv" value = "<?php echo 
$_SESSION["verifyEmIPv"]; ?>" />
 <ul id="verifyEMAIL_notice" class="success-notification"><li>Email 
Has been sent, hurry you have only 5 minutes to verify your IP and 
activate 
your account.</li></ul><br />
<ul id="re_verifyEMAIL_notice" style="display:none;" class="success-
notification"><li>Email Has been sent, hurry you have only 5 minutes 
to verify your IP and activate your account.</li></ul><br /><h3>
<p>Keep in 
mind. Do not close this window, until you verify yourself.<br />If 
time 
limit exceed you can request for new code from this page.</p><br />
<button id="vE_rebtn">Click To Resend Now!</button></h3>   
<div id="vE_resending" style="display:none;">Resending.... Please 
Wait.</div></h3>

答案 2 :(得分:0)

如果您只想发送数据并获得结果,那么您在这里做得太多了。只需创建一个jQuery函数,将它放在head标签或任何你想要的.js文件中,并在你点击任何其他你想要的元素时调用它。传递您想要的ID或电子邮件ID。发送前验证,然后发送呼叫。从Web服务或API接收数据后,只需在任何范围或警告框中显示结果。

为何复杂化?