需要帮助Jquery和Ajax

时间:2021-12-04 02:04:57

Currently im developing a web application using Ajax to display the notification message. But I don't know why the closing button on the notfication message dialog is not working in any IE browser(tested with 9.0 and 7.0) but its working fine with Firefox And the werid thing is that if I hardcoded jquery code in my html code it work fine with IE browser.

目前我正在使用Ajax开发一个Web应用程序来显示通知消息。但是我不知道为什么notfication消息对话框上的关闭按钮在任何IE浏览器中都没有工作(用9.0和7.0测试)但它在Firefox上工作得很好而且如果我在我的html代码中硬编码jquery代码那么可疑它可以与IE浏览器一起使用。

I'm thinking when the message sent across from Ajax is somehow affecting the javascript but I couldn't figure out the reason.

我正在考虑从Ajax发送的消息是否以某种方式影响了javascript,但我无法弄清楚原因。

Can anyone please help me out? Thanks so much in advance!

有人可以帮帮我吗?非常感谢提前!

Here is my jquery notification box message code

这是我的jquery通知框消息代码

<div class="notification information png_bg">
<a href="#" class="close">
<img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
        <div> You have New Lead Notification </div>
</div>

Here is my html code to trigger the ajax notfication message

这是我的html代码,用于触发ajax notfication消息

                            <label for ="msg">notice</label>
                            <input type="text" name ="msg" id ="msg" />
                            <a href ="#" id="getNotice"> get notice!</a>

 <script type = "text/javascript">
              $(function()
                {
                    $("#getNotice").click(function()
                        {
                             $.post("/async/getnotification" , {},
                             function(response)
                              {
                                var notice = $(response);
                                 $("#notices").prepend(notice);
                                     });
                                      return false;
                                });
                       });

        </script>
     <div id ="notices">

   </div>

Here is the javascript code to trigger the close function for the close button

这是触发关闭按钮的关闭功能的javascript代码

        $(".close").click(
            function () {// Links with the class "close" will close parent
                $(this).parent().fadeTo(400, 0, function () { 
                                        $(this).slideUp(400);
                });
                return false;
            }
        );

1 个解决方案

#1


1  

I finally figured out the problem is related to the Javascript DOM therefore i have to replace click with live

我终于弄清楚问题与Javascript DOM有关,因此我必须用live替换click

For more info visit link

有关更多信息,请访问链接

Solutions

解决方案

    $(".close").live('click',
        function () {
            $(this).parent().fadeTo(400, 0, function () { 
                $(this).slideUp(400);
            });
            return false;
        }
    );

#1


1  

I finally figured out the problem is related to the Javascript DOM therefore i have to replace click with live

我终于弄清楚问题与Javascript DOM有关,因此我必须用live替换click

For more info visit link

有关更多信息,请访问链接

Solutions

解决方案

    $(".close").live('click',
        function () {
            $(this).parent().fadeTo(400, 0, function () { 
                $(this).slideUp(400);
            });
            return false;
        }
    );