Ajax嵌套调用 (jquery) $.ajaxSettings.async = false;
Posted genghuilove
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ajax嵌套调用 (jquery) $.ajaxSettings.async = false;相关的知识,希望对你有一定的参考价值。
<!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;的主要内容,如果未能解决你的问题,请参考以下文章