码迷,mamicode.com
首页 > Web开发 > 详细

Ajax嵌套调用 (jquery) $.ajaxSettings.async = false;

时间:2016-12-17 14:25:06      阅读:482      评论:0      收藏:0      [点我收藏+]

标签:rip   eth   append   and   pts   nbsp   handle   span   length   

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../javascripts/jquery-2.1.4.js"></script>
    <script>
        window.onload = function () { 
            $.post("Handler.ashx", { flag: 1 }, function (_data) {
                if (_data) {
                    var html = "";
                    html += "<table border=‘1‘>";
                    for (var i = 0; i < _data.length; i++) {
                        var pj00401 = _data[i].pj00401;
                        html += "<tr>";
                        html += "<td>" + _data[i].pj00402 + "</td>";
                        html += "<td>" + getHtml(pj00401) + "</td>";
                        html += "</tr>";
                    }
                    html += "</table>";
                    $("#div1").append(html);
                }

            }, "json");  

            var getHtml = function (_pj00401) { 
                var _html = "";
                $.ajaxSettings.async = false;//重要设置
                $.get("Handler.ashx", { flag: 102, pj00401: _pj00401 }, function (_data) {
                    if (_data) {
                        _html = "<table>";
                        _html += "<tbody> ";
                        for (var i = 0; i < _data.length; i++) {
                            _html += "<tr>";
                            _html += "<td>" + _data[i].pj00402 + "</td>";
                            _html += "</tr>";
                        }
                        _html += "</tbody>";
                        _html += "</table>";
                    }
                }, "json");
                return _html;
            }
             
        }
    </script>
</head>
<body>

    <div id="div1"></div>

</body>
</html>

 

Ajax嵌套调用 (jquery) $.ajaxSettings.async = false;

标签:rip   eth   append   and   pts   nbsp   handle   span   length   

原文地址:http://www.cnblogs.com/genghuilove/p/6189493.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!