第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么 PHP 看不到來(lái)自 ajax js 的值?

為什么 PHP 看不到來(lái)自 ajax js 的值?

PHP
胡說(shuō)叔叔 2023-09-30 15:29:17
當(dāng)我從 JS 端得到結(jié)果時(shí),該值變?yōu)?true。但我想將值填充到我的 PHP 文件中,所以我使用了 ajax。當(dāng)我刪除 PHP 中的 ifisset 函數(shù)時(shí),出現(xiàn)“未定義索引”錯(cuò)誤。HTML 端     <form method="post" onsubmit="return false;"  class="form-inline">     <input type="email" name="email" id="subscriber_email" placeholder="Your E-mail" >     <button type="submit" id="subscribe_newsletter" class="btn newsbox-btn w-       100"onclick="gonder()">Subscribe</button>                                   </form>       <div id="subscribe_message"></div>        <p id="succes" class="mt-30"></p>jS側(cè)<script  type="text/javascript">function gonder(){var ad=$("input[name='email']").val();$.ajax({    type:"POST",    url:"myphpfile.php",    data:ad,   // I also tried  {'sendingData':ad} but it doesn't work.    success:function(sonuc){        $("#subscribe_message").html(sonuc);        $("#succes").html(sonuc);               }}) }</script>以及 PHP 端<?php    if(isset($_POST["ad"])){    $x=$_POST["ad"];    echo $x;     }   else{      echo "There is nothing coming from the script.";      }     ?>
查看完整描述

1 回答

?
哈士奇WWW

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超6個(gè)贊

您正在發(fā)送一個(gè)值,但您沒(méi)有發(fā)送具有該值的密鑰。例如,如果值為123則您只發(fā)送123,沒(méi)有其他內(nèi)容。ad所以這不會(huì)找到它,因?yàn)榘l(fā)送的數(shù)據(jù)中沒(méi)有調(diào)用密鑰:

$_POST["ad"]

為值添加一個(gè)鍵:

data: { ad: ad }

或者甚至簡(jiǎn)單地:

data: { ad }


查看完整回答
反對(duì) 回復(fù) 2023-09-30
  • 1 回答
  • 0 關(guān)注
  • 83 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)