开发者

Ajax alert - How to add 'don't remind again button'?

开发者 https://www.devze.com 2023-03-08 04:19 出处:网络
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.

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.


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 a confirm() 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消