ajax document.write 问题

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://dev.uuu9.com/js/jQuery/jquery-1.4.2.min.js"></script>
</head>
<body>
    <script>
        jQuery(document).ready(function () {
            jQuery.getJSON("调用接口", function (data) {
                jQuery.each(data, function (i, item) {
                    var con = '<li><b>' + item.count + '</b><a href="' + item.url + '" target="_blank" title="' + decodeURI(item.title) + '">' + decodeURI(item.title) + '</span></a></li>';
                });
                document.write("1111");
            });
        });
    </script>
</body>
</html>

异步调用 时 使用document.write() 发现不执行。

查找资料得出原因:document.write 相当于对流进行操作,用ajax前,document 已经关闭了,再write操作已经无效了。

原文地址:https://www.cnblogs.com/skykang/p/2270534.html