更改url并显示ajax内容


change the url and display the ajax content

$(function(){
  $("a[rel='tab']").click(function(e){
    //get the link location that was clicked
    pageurl = $(this).attr('href');
    $("#Content").fadeOut(800);
    setTimeout(function(){
      $.ajax({url:pageurl+'?rel=tab',success: function(data){
        $("#Content").fadeIn(900);  
        $('#Content').html(data);
      }});
    }, 900);
    //to get the ajax content and display in div with id 'content'
    //to change the browser URL to 'pageurl'
    if(pageurl!=window.location){
      window.history.pushState({path:pageurl},'',pageurl);  
    }
    return false;  
  });
});

我想通过ajax改变url的内容,,我使用上面的代码,但它是使网站非常慢。当我点击网站上的任何页面时,我怎样才能使它快速?

谢谢

fadeIn()/fadeOut()/setTimeout()的延迟减慢了速度。减少或删除它们

$(function(){
  $("a[rel='tab']").click(function(e){
    //get the link location that was clicked
    pageurl = $(this).attr('href');
    $("#Content").fadeOut(50);
    $.ajax({url:pageurl+'?rel=tab',success: function(data){
      $('#Content').html(data);
      $("#Content").fadeIn(25);  
    }});
    //to get the ajax content and display in div with id 'content'
    //to change the browser URL to 'pageurl'
    if(pageurl!=window.location){
      window.history.pushState({path:pageurl},'',pageurl);  
    }
    return false;  
  });
});