dongzhuo3202 2012-03-19 21:39
浏览 40
已采纳

如何通过PHP插入一些数据后使用js发出警报

I am inserting some information to my database and i am using the following pattern main page has a form. I send values entered in the form to controller and then insert it to database and back to my main page using header(location:../etc).
What i want is that whenever i add some data in my db i want to show some alert that data has been added or anything to give feedback to user.
Can someone suggest me a solution.

Thanks

  • 写回答

1条回答 默认 最新

  • duanju6788 2012-03-19 21:42
    关注

    You can use Ajax. I suggest using jQuery because then you can just pass a callback function to the get request which it will call when it gets the return. For example:

     $.get("insertToDB.php", function(data){alert("Data Loaded: " + data);});
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥25 关于##爬虫##的问题,如何解决?:
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误