简体   繁体   English

ajax iframe 重新加载后图像未显示

[英]image not showing after ajax iframe reload

I'm working on profile system where, when the user clicks the form submit buttons the iframe reloads which shows the user profile and updates the content.我正在研究配置文件系统,当用户单击表单提交按钮时,iframe 会重新加载,显示用户配置文件并更新内容。 Reloading is working perfectly but the image is not showing after 1st reload/refresh.重新加载工作正常,但第一次重新加载/刷新后图像未显示。 Means when the user visits the images is showing up successfully but when the user saves the data ie changes the images and saves it the image in iframe does not appear, I've to reload the page then the image appears.意味着当用户访问图像时显示成功,但是当用户保存数据即更改图像并将其保存时,iframe 中的图像不会出现,我必须重新加载页面然后图像才会出现。

This is ajax success code这是ajax成功码

$("#profile_iframe").fadeOut("slow", function() { //fadesout the iframe
        $('#profile_iframe').hide().attr('src', (index, attr) => { //Reloads the iframe
          return attr;
        });
        setTimeout(() => {
          $('#profile_iframe').fadeIn('slow'); //fades in after reload
        }, 2000);
      });

The other content is refreshing successfully, only image is not showing up.其他内容刷新成功,只有图片没有显示。 So there's no problem in ajax.所以ajax没有问题。

Then I tried this code然后我尝试了这段代码

$("#profile_iframe").fadeOut("slow", function() {
        $('#profile_iframe').hide().attr('src', (index, attr) => {
          return attr;
        });
      });
      $('#profile_iframe').fadeIn('slow');

Here the image is showing successfully after ajax submit, but the fadeOut fadeIn does not work correctly.此处图像在 ajax 提交后成功显示,但淡出淡入无法正常工作。 After submitting the iframe fades out the immediately fadeIn and then reloads with a white snap.提交 iframe 后,立即淡出淡入,然后以白色快照重新加载。 It doesn't looks good.看起来不太好。

I even tried to wait for the iframe to reload and then fade in, but then the image does not show up again, I think when I try to put the fadeIn function in another function the image does not show up.我什至尝试等待 iframe 重新加载然后淡入,但随后图像不再显示,我想当我尝试将 fadeIn function 放入另一个 ZC1C425268E68385D14AB5074C17A 时,图像不会显示。

I know its bit lengthy, but some help would be appreciated!我知道它有点冗长,但我们将不胜感激! Thankyou谢谢

Finally after some research, got it Added a delay in fadeIn(2000);最后经过一番研究,得到它在fadeIn(2000)中添加了一个延迟; Thanks谢谢

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

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