My jQuery code not working in IE

2019-08-10 02:32发布

The below code rocks in Chrome and FF but not working in IE I checked for similar questions in SO. Some didn't help me and some I couldn't understand as I am a newbie to jQuery. Please help me in fixing this error.

<script type="text/javascript">
$(document).ready(function(){
    $(function(){
       $('#container').load('mypage.aspx #div1');
    });
});
</script>

2条回答
欢心
2楼-- · 2019-08-10 03:00

Try opening the IE Developer toolbar and watching the network trace. Is the request to mypage.aspx coming back? Or does it return a 500 server error response code? Does it even fire the request at all?

Another option, try changing you code to this:

<script type="text/javascript">
$(document).ready(function(){
       $('#container').load('mypage.aspx #div1');
});
</script>
查看更多
别忘想泡老子
3楼-- · 2019-08-10 03:23

I don't know if it makes a difference specifically for IE, but you are double-declaring the function scope.

<script type="text/javascript">
$(document).ready(function(){
   $('#container').load('mypage.aspx #div1');
});
</script>

You may try and see if this works.

查看更多
登录 后发表回答