应用场景:
用户评论后,在合适位置弹出“评论成功”,2秒钟后自动消失,提示用户评论成功。
html:
{#评论成功提示#} <div class="popup_con" style="display: none; margin-left: 300px"> <div class="popup" > <p style="color: red; font-size: 16px">评论成功!</p> </div> <div class="mask"></div> </div>
js:
// 评论成功提示定时器 // 定一定时器函数 function showsuccessmsg() { $('.popup_con').fadein('fast', function () { settimeout(function () { $('.popup_con').fadeout('fast', function () { }); }, 2000) }); } // 提交评论 $("#form_comment").submit(function (event) { event.preventdefault(); var comment = $('#comment').val(); var data = { "comment": comment }; $.ajax({ url: "/task_mgm/taskinfo_comment=" + taskid, type: "post", data: json.stringify(data), contenttype: "application/json", // 传给后端的数据类型 datatype: "json", // 接收后端的数据类型 success: function (resp) { if (resp.error == 'ok') { showsuccessmsg(); {#alert('评论成功');#} $('#comment').val(''); //清空评论框 } else { alert('评论失败'); } } }) })
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
MFC的静态库.lib、动态库.dll(包含引入库.lib)以及Unicode库示例
CTF 刷题记录(一) 白云新闻搜索(手动与自动化SQL注入)
javascript如何使用函数random来实现课堂随机点名方法详解
网友评论