【发布时间】:2014-10-06 09:28:26
【问题描述】:
我的php代码
function MailList()
{
$this->Form['email'] = $_POST["email"];
$index = $this->mgr->getMailList($_POST["email"]);
}
//sql code
function getMailList($email)
{
$mailArray = Array();
$sql = "select vchEmail as mailName from tbDownloadDetails where vchEmail='".$email."'";
$result = mysql_query($sql, $this->con);
$isexist=false;
while ($row = mysql_fetch_array($result))
{
$isexist=true;
array_push($mailArray, $row['mailName']);
}
return ($mailArray);
}
Ajax 代码
function getMailList(e)
{
$value=e;
$.ajax({
url:'http://example.com/report/' + "filedownload.html",
type:"POST",
data:{action:'MailList',email:$value},
dataType:"html",
success:function (resp) {
if (resp !== '') {
alert("Success");
} else {
alert("Fail");
return false;
}
}
});
return false;
}
这是我的代码。但它不起作用。当我输入电子邮件 ID 时,它总是显示(警报)成功,如果它不存在于 db 中。也就是说,代码总是给出正值。如何更正代码。 提前谢谢....
【问题讨论】:
标签: javascript php ajax smarty