Replace current page with ajax content

前端 未结 9 1263
南旧
南旧 2020-12-05 04:50

I have a page with a dialog window which sends ajax post data to server and receives a response. During development, there can be two responses - one regular (this is not th

9条回答
  •  隐瞒了意图╮
    2020-12-05 05:31

    You may also try to use data URL's, the latest versions of the major browsers supporting it:

    function utf8_to_b64( str ) {
        return window.btoa(unescape(encodeURIComponent( str )));
    }
    
    function loadHtml(html)
    {
        localtion.href='data:text/html;base64,'+utf8_to_b64(html);
    }
    

    This way, you can load any html page you want in runtime.

提交回复
热议问题