首页 >> js开发 >> jsJS定时器如何实现提交成功提示功能js大全
jsJS定时器如何实现提交成功提示功能js大全
发布时间: 2021年1月13日 | 浏览:
| 分类:js开发
应用场景:应用场景:
用户评论后,在合适位置弹出“评论成功”,2秒钟后自动消失,提示用户评论成功。HTML:HTML:
{#评论成功提示#}
{#评论成功提示#}
js: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('评论失败');
}
}
})
})
// 评论成功提示定时器
// 定一定时器函数
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('评论失败');
}
}
})
})以上就是本文的全部内容,希望对大家的学习有所帮助。
用户评论后,在合适位置弹出“评论成功”,2秒钟后自动消失,提示用户评论成功。HTML:HTML:
{#评论成功提示#}
{#评论成功提示#}
js: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('评论失败');
}
}
})
})
// 评论成功提示定时器
// 定一定时器函数
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('评论失败');
}
}
})
})以上就是本文的全部内容,希望对大家的学习有所帮助。
相关文章:
- jsvue 页面回退mounted函数不执行的解决方案js大全
- jsVue组件跨层级获取组件操作js大全
- js解决VUE mounted 钩子函数执行时 img 未加载导致页面布局的问题js大全
- js解决vue页面渲染但dom没渲染的操作js大全
- js谈一谈vue请求数据放在created好还是mounted里好js大全
- js解决vue的router组件component在import时不能使用变量问题js大全
- js在vue中使用防抖函数组件操作js大全
- jsVue中的this.$options.data()和this.$data用法说明js大全
- jsElement Breadcrumb 面包屑的使用方法js大全
- js解决vue动态路由异步加载import组件,加载不到module的问题js大全