質問

私のテーマの上部にスタイルスイッチャーバーを持っています。これは、ほとんどの部分のために働くが、あなたは新しいスタイルを見るためにF5または[更新]をクリックする必要があります。どのように私は成功した実行時に自動更新には、このjQueryのを終了しますか?

    jQuery.fn.styleSwitcher = function(){
    $(this).click(function(){
        loadStyleSheet(this);
        return false;
    });
    function loadStyleSheet(obj) {
        $('body').append('<div id="overlay" />');
        $('body').css({height:'100%'});
        $('#overlay')
            .css({
                display: 'none',
                position: 'absolute',
                top:0,
                left: 0,
                width: '100%',
                height: '100%',
                zIndex: 1000,
                background: 'black url(http://mytheme.com/loading.gif) no-repeat center'
            })
            .fadeIn(500,function(){
                $.get( obj.href+'&js',function(data){
                    $('#stylesheet').attr('href','css/' + data + '.css');
                    cssDummy.check(function(){
                        $('#overlay').fadeOut(500,function(){
                            $(this).remove();
                        }); 
                    });
                });
            });
    }
    var cssDummy = {
        init: function(){
            $('<div id="dummy-element" style="display:none" />').appendTo('body');
        },
        check: function(callback) {
            if ($('#dummy-element').width()==2) callback();
            else setTimeout(function(){cssDummy.check(callback)}, 200);
        }
    }
    cssDummy.init();
}
$.ajax({
  success:function(){
       $('#overlay').load('http://mytheme.com');
  }
 });
役に立ちましたか?

解決

あなたが使用することができます。

success: function() {
    window.location.reload(true);
}

他のヒント

window.location.reload(true); 

トリックを行います。

window.location = window.location.pathnameは、リフレッシュを実行します。

あなたは、これはあなたを助けるかもしれません使用することができます。

私はページをリフレッシュするためのからこのコードを得た。

success: function(data){
   if(data.success == true){ // if true (1)
      setTimeout(function(){// wait for 5 secs(2)
           location.reload(); // then reload the page.(3)
      }, 5000); 
   }
}

を使用できます:

document.location.reload();
scroll top