Ajax 警报 - 如何添加“不再提醒按钮”?
我是阿贾克斯新手。
加载页面时我会收到警报,向用户显示特定用户的注释。当查看该用户的个人资料时,将出现包含注释的警报。
我希望用户在此警报上有一个勾选按钮,表示不再提醒?理想情况下,此复选框会调用一个函数将“读取”列设置为 1,这样下次显示用户个人资料时就不会显示警报了?
希望我解释正确。
$.ajax({
type: "POST",
url: "ajax.aspx/GetMembersNotes",
data: '{' +
'nameID:"' + $('#nameID').val() + '",' +
'addrID:"' + $('#addrID').val() + '"' +
'}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
var data = json_parse(msg.d);
if (!data.error) {
$.each(data, function(d) {
if (data[d].read = 1){
alert(data[d].notes);
}
});
}
else {
alert("Cannot get memeber's notes data\n" + data.error);
}
},
error: function(msg) {
alert('Get Memeber\'s Notes Failure' + msg);
}
});`
上面显示了警报。在 GetMemberNotes 函数中,构建 JSON 字符串并返回注释并读取。
I am new to Ajax.
I have an alert when a page is loaded which shows the user a note for a specific user. When the profile of this user is viewed the alert containing the note will appear.
What i would like is for the user to have a tick button on this alert which says dont remind again? This checkbox would ideally call a function to set column 'read' to 1, so next time the users profile is displayed it will not show the alert?
Hope i explained correctly.
$.ajax({
type: "POST",
url: "ajax.aspx/GetMembersNotes",
data: '{' +
'nameID:"' + $('#nameID').val() + '",' +
'addrID:"' + $('#addrID').val() + '"' +
'}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
var data = json_parse(msg.d);
if (!data.error) {
$.each(data, function(d) {
if (data[d].read = 1){
alert(data[d].notes);
}
});
}
else {
alert("Cannot get memeber's notes data\n" + data.error);
}
},
error: function(msg) {
alert('Get Memeber\'s Notes Failure' + msg);
}
});`
The above shows the alert. In the GetMemberNotes function a JSON string is built and returns notes and read.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法修改
alert()
框。这是本土的东西。您无法对其进行任何控制,也无法修改其行为。您唯一能做的就是在上面添加纯文本。您可以使用confirm()
框(它给出了是/否功能),但它并不完美。您可以尝试构建自己的对话框,或使用 jQuery UI 的对话框 以获得最灵活的结果。
You cannot modify an
alert()
box. It is native stuff. You cannot put any controls on it and cannot modify its behavior. The only thing you can do is put plain text on it. You might use aconfirm()
box (it gives a Yes/No functionality), but it is not perfect.You can try building your own dialog, or use jQuery UI's Dialog for the most flexible results.