0
這是我第二天使用php並仍在使用jQuery/ajax進行學習。不要笑。在ajax調用後在頁面上顯示響應
我有這個代碼傳遞一個電子郵件地址到一個PHP頁面。
jQuery.getJSON("get-alert.php?returnformat=json",{"email":email},function(res,code){
/*if(res == whatever){
jQuery("#resSend").show();
}*/
});
PHP腳本(簡稱爲清楚起見):
if(!$mail) {
echo "Error sending email";
} else {
echo "Successfully sent, thank you for your interest!";
}
,我想展示的onSuccess股利如下:
<div id="resSend" class="opq2" style="display:none">Successfully sent. Thank you for your interest!</div>
什麼我不明白是怎麼從php腳本中獲取「成功發送」消息,並將其顯示在調用頁面上,而不是取消隱藏div。
這不是JSON的。 – SLaks
我知道。我使用getJSON來處理所有事情,它確實有效。建議其他方式,然後請 – user460114
如果你不想得到JSON,不要調用'getJSON'。你有沒有看到'.ajax()'? – SLaks