douxiong3234 2013-01-07 20:10
浏览 33
已采纳

向按钮单击添加警报

I have been trying to add a alert to my button which updates a users details in a database.

I have tried adding a onclick method directly to the button and using functions but it doesn;t seem to work.

My button is;

<input type="submit" id="profileclick" value="Update" class="button-link"/>

And I am submitting the form by: (if it is important)

<form id="profile" method="post" action="../script/updateUserDetails.php">

One of the ways I tried was

$('#profileclick').click(function(){
 alert('Your details have been updated');
 $('#profile').submit();
});

In all instances the details update but I do not receive a alert.

  • 写回答

2条回答 默认 最新

  • duanlu7680 2013-01-07 20:12
    关注
    $('#profileclick').click(function(){    
         alert('Your details have been updated');
         $('#profile').submit();
    });
    
    
    $('#profile').submit(function( e ){
             e.preventDefault();
    
             // ........ AJAX SUBMIT FORM
    });
    

    Or simply add a delay before you submit using setTimeout ...

    $('#profileclick').click(function(){    
         alert('Your details have been updated');
         setTimeout(function(){
                 $('#profile').submit();
         }, 2000);        
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装