简体   繁体   中英

Reload parent after closing Iframe doesn't update dynamic content (PHP/Smarty)

I'm using Fancybox to load and Iframe with a form. After I post it, onsubmit calls "return onSubmitForm() "

<script type="text/javascript">
function onSubmitForm() {
parent.jQuery.fancybox.close(); 
window.parent.location.reload(true);
}
</script>

So Php/Smarty is loading the dynamic content OK in my database. I can also close the Iframe. BUT, after reloading the parent, it's dynamic content is not updated.

I have doing several tests and it only works occasionally ( 1 in 10 ). The previous content gets sticky .

I also started using " nocache " or " caching=0 " (for PHP/Smarty variables). So far it doesn't help.

If I reload manually the browser, it works.

Thanks!

Diego

Inside the iframe (with the form) just try closing the box

function onSubmitForm() {
  parent.jQuery.fancybox.close(); 
}

...then, in the parent page (from where you called fancybox) add this API option to your script... something like

jQuery(".fancybox").fancybox({
    type: "iframe",
    width: 640, // or whatever
    height: 320,
    afterClose : function() {
        location.reload();
        return;
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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