dongqiao3927 2018-08-25 06:34
浏览 94

在Laravel模型中放置javascript警报 - 无法从Laravel模型中提醒消息

I want to alert a invalid message to the user from Laravel Model, I wrote the code but its not alerting. This piece of code works perfectly in simple PHP with wamp but this does not work with Laravel Model.

I Know this can be done using Ajax response and show the message in actual JS file instead of Model/Controller file but I want to know if there is a way to alert a JavaScript from Model itself instead of again AJAX call.

following is the function in my Model PHP where I am trying to alert a message:

public static function Login_Authenticator($request)
{
    if($ldapconn)
    {
        $ldapbind = @ldap_bind($ldapconn, $ldapuser, $ldappass) or  die("<script>alert('Invalid Credentials');</script>");
    }

}
  • 写回答

2条回答 默认 最新

  • doudeng1870 2018-08-25 07:02
    关注

    I don't think die will work here try echo instead of die. Although, I feel this is bad practice because php should be used at the server side only. Try to add javascript in the view itself.

    评论

报告相同问题?

悬赏问题

  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python