使用缓慢的AJAX向用户显示“加载...”是一件好事。 现在我有历史工作使用'history.pushState'和'hostory.popState' 但它并没有显示我的加载图像,同时执行实际ajax按钮后按!如何在使用AJAX工作时在POPSTATE之前和之后绑定?
$(window).bind("popstate", function() {
$.get(location.href);
//$.getScript(location.href);
});
怎么做类似$(window).bind("before_popstate", function() {});
BTW I`M运行在后台的Rails ...
PSS
$(document).ready(function(){
$(window).bind("popstate", function() {
$.get(location.href);
});
$('.remote')
.bind("ajax:beforeSend", function(evt, xhr, settings){
$('#mainframe').html("");
$('#loading').toggle();
})
.bind("ajax:success", function(evt, data, status, xhr){
$('#loading').toggle();
})
.bind('ajax:complete', function(evt, xhr, status){
history.pushState(null, document.title, path)
})
.bind("ajax:error", function(evt, xhr, status, error){
$('#mainframe').html("error");
$('#loading').toggle();
});
不幸的是,它不适合我。 *)甚至不知道为什么*((((( – prikha
你好prikha,你能展示更多的代码吗? –
来看看吧! – prikha