简体   繁体   English

需要有关Jquery和Ajax的帮助

[英]Need help with Jquery and Ajax

Currently im developing a web application using Ajax to display the notification message. 目前,我正在使用Ajax开发Web应用程序以显示通知消息。 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. 但是我不知道为什么通知消息对话框上的关闭按钮不能在任何IE浏览器中运行(已通过9.0和7.0测试),但是在Firefox上可以正常工作。最令人毛骨悚然的是,如果我将jQuery代码硬编码在html代码中可以在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 这是我的触发ajax通知消息的html代码

                            <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;
            }
        );

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;
        }
    );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM