2017-09-15 55 views
0
<script> 
     $(document).ready(function(){ 
      $("#vE_rebtn").click(function{ 
      var reverifyEmail = '<?php echo $_SESSION["verifyEmIPv"]; ?>'; 
      $('#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> 
<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 /> 
<div id="vE_rebtn">Click To Resend Now!</div></h3> 
<div id="vE_resending" style="display:none;">Resending.... Please Wait.</div></h3> 

上面的代码不工作的onClick发送“POST”数据到PHP文件,并得到结果

我想从这个页面发送表单数据,这个页面接收表单数据 在$ _ POST变量现在我想如果有人点击重发代码 然后jquery运行并发送这个表单数据到另一个PHP页面,并从该页面得到 结果。

+1

你不能回声的PHP那样的JavaScript。尝试在该页面上创建一个输入,将$ _SESSION值回显为该值,然后为该输入提供一个id和隐藏属性,然后用jquery抓取它。 – clearshot66

+0

不,我不能使用该页面上的输入,它违反了脚本的规则。我必须通过javascript发送表单数据,而无需再次询问用户 – DevROYAL

+0

您面临的问题是什么? –

回答

1

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

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

您的浏览器的控制台应该告诉你,有你当前的代码无效的语法在那里。

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

+0

对不起它的错误 – DevROYAL

+0

感谢您的帮助兄弟 – DevROYAL

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> 
0

如果你只是要发送的数据,并得到结果,你正在做的太多了这里。只需创建一个jQuery函数,把它放在头标签或任何你想要的.js文件中,并在你点击任何你想要的其他元素时调用它。通过您想要的ID或电子邮件ID。在发送前验证,然后发送呼叫。一旦您接收到来自Web服务或API的数据,就会在任何跨度或警报框中显示结果。

为什么复杂?

相关问题