问题
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