2017-09-15 66 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的數據,就會在任何跨度或警報框中顯示結果。

爲什麼複雜?

相關問題