简体   繁体   English

ajax调用后如何模糊内容

[英]How to blur content after ajax call

I'm using ajax call on my page which changes content of a division block.我在我的页面上使用 ajax 调用来更改分割块的内容。 What I wanted is to make that div content blur until new content loaded.我想要的是使该 div 内容模糊,直到加载新内容。

So,所以,

Step 1 : click on button.第1步:点击按钮。

Step 2 : blur the content of that division block and user can't select anything now from that division.第 2 步:模糊该分区块的内容,用户现在无法从该分区中选择任何内容。

Step 3 : Content loaded and gets back to normal state.第 3 步:加载内容并恢复正常状态。

Step 1 and 3 are already done.第 1 步和第 3 步已经完成。 What I need is step 2.我需要的是第2步。

Lets say your main content block has the id 'main'.假设您的主要内容块具有 id 'main'。

in your button's onclick, before loading content etc.. do:在您的按钮的点击中,在加载内容等之前。做:

var pos = $('#main').offset();
var size = { w: $('#main').outerWidth(), h: $('#main').outerHeight() };
$('<div class="main_overlay"></div>')
  .css({left: pos.left+'px', top: pos.top+'px', width: size.w+'px', height: size.h+'px'})
  .appendTo('body');

in your css file, add:在您的 css 文件中,添加:

.main_overlay {
  position: absolute;
  background-color: #fff;
  opacity: 0.5;
}

once, everything is loaded up, and you are ready to unblur, do:一次,一切都加载完毕,你准备好去模糊,做:

$('.main_overlay').remove();

如果您使用 jQuery, ShowLoading 插件可以很好地完成此工作。

I would create a function with onreadystatechange and set a blur to that area until readystate==4 .我会创建一个带有onreadystatechange的函数并对该区域设置模糊,直到readystate==4 Now the type of blur and how you want that done would be up to you but I used a similar idea to fade text in and out for an ajax call with my fade function in something like this.现在模糊的类型以及您希望如何完成将取决于您,但我使用类似的想法来淡入和淡出文本,以使用我的淡入淡出函数进行 ajax 调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM