我希望在输入else
. 我找到了两种方法来发出警报。
echo "<script type=\"text/javascript\">alert(\"Error al crear sugerencia\");</script>";
任何一个
echo '<script language="javascript">alert("Error al crear sugerencia");</script>';
但它不会提醒我,它会打印在控制台上
我把 PHP 代码留给你
$asunto = str_replace("'", "''", $asunto);
$comunicacion = str_replace("'", "''", $comunicacion);
echo $insertNoticia="insert into ib_noticia_interna (ID_NOTICIA_INTERNA,ASUNTO_NOTICIA,CREADOR,CUERPO_NOTICIA,fecha_inicio_vis,fecha_fin_vis,imagen) values(ID_NOTICIA_INTERNA.nextval,'$asunto','$selectorDep','$comunicacion','$fechaIni','$fechaFin','$url')";
$parseNoticia = oci_parse($intranetconn, $insertNoticia);
$execNoticia = oci_execute($parseNoticia);
if ($execNoticia) {
createNotificacion($intranetconn,$asunto,$fechaIni,$fechaFin,$selectorDep,'comunicacion');
}else{
echo "<script type=\"text/javascript\">alert(\"Error al crear sugerencia\");</script>";
}
如何在 php 中发出警报?为什么它是由控制台打印的并且它适用于其他人?
我发现了这个错误并报告它以防有人遇到同样的问题。
原来我正在运行的 PHP 是通过 AJAX 调用的。
事实证明,在执行
console.log(data)
所有php 时echos
,returns
它们都由 console.log 显示。我已经放置
$('body').append(data);
并添加了返回 php.ini 的脚本。正确代码: