My jQuery code not working in IE

前提是你 提交于 2020-01-15 14:25:50

问题


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>

回答1:


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>



回答2:


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.



来源:https://stackoverflow.com/questions/9008350/my-jquery-code-not-working-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!