gpt4 book ai didi

javascript - 如何避免PHP中的警告框

转载 作者:行者123 更新时间:2023-11-28 11:54:31 24 4
gpt4 key购买 nike

我只想在 echo 时收到警报。当我没有给出 echo 语句时,会显示空警报框。我想仅在“if”条件之后显示警报。

 $.ajax({
type:'post',
url:'email.php',
data:{email: email},
success:function(msg){
alert(msg);
}
});

email.php

$s=$_POST['email'];
include "config.php";
$echeck="select email from register where email='".$_POST['email']."'";
$echk=mysql_query($echeck);
$ecount=mysql_num_rows($echk);
if($ecount>=1 && $s!='0')
{
echo "Email already exists";
}

最佳答案

尝试一下

$.ajax({
type:'post',
url:'email.php',
data:{email: email},
success:function(msg){
if($.trim(msg) != '') {
alert(msg);
}
}
});

您也可以使用长度,例如

msg = $.trim(msg);
if(msg.length > 0) {
alert(msg);
}

关于javascript - 如何避免PHP中的警告框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27518580/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com