在IE8中显示php页面的AJAX选项卡问题


AJAX Tab issue for displaying php page in IE8

<ul id="nav">
  <li><a href="page_1.html">Page 1</a></li>
  <li><a href="page_2.html">Page 2</a></li>
  <li><a href="page_3.html">Page 3</a></li>
</ul>
<div id="ajax-content">This is default text, which will be replaced</div>
<script>
$(document).ready(function() {
    $("#nav li a").click(function() {
        $("#ajax-content").empty().append("<div id='loading'><img src='images/loading.gif' alt='Loading' /></div>");
        $("#nav li a").removeClass('current');
        $(this).addClass('current');
        $.ajax({ url: this.href, success: function(html) {
            $("#ajax-content").empty().append(html);
            }
    });
    return false;
    });
    $("#ajax-content").empty().append("<div id='loading'><img src='images/loading.gif' alt='Loading' /></div>");
      $('#page_1').addClass('current');
    $.ajax({ url: 'page_1.html', success: function(html) {
            $("#ajax-content").empty().append(html);
    }
    });
});
</script>

当我使用page_2.html时,上面的代码工作正常,但是当我使用page_2.php当我在Internet Explorer 8中使用时,它不起作用。我不明白如何解决这个问题。

尝试完整的网址。

$("#nav li:first a").click();//而不是重复代码

显示 IE 中的 AJAX 错误的示例:

$.post("update.php",{data:"blabla"},function(){
 /*... stuff to do on success...*/
},"json").fail(function(XMLHttpRequest,textStatus,errorThrown){
 /*... display the errors here so you know what is wrong...*/
 alert(textStatus+": "+errorThrown);
});