<small id='racIe'></small><noframes id='racIe'>

  • <tfoot id='racIe'></tfoot>
  • <legend id='racIe'><style id='racIe'><dir id='racIe'><q id='racIe'></q></dir></style></legend>

        • <bdo id='racIe'></bdo><ul id='racIe'></ul>
        <i id='racIe'><tr id='racIe'><dt id='racIe'><q id='racIe'><span id='racIe'><b id='racIe'><form id='racIe'><ins id='racIe'></ins><ul id='racIe'></ul><sub id='racIe'></sub></form><legend id='racIe'></legend><bdo id='racIe'><pre id='racIe'><center id='racIe'></center></pre></bdo></b><th id='racIe'></th></span></q></dt></tr></i><div id='racIe'><tfoot id='racIe'></tfoot><dl id='racIe'><fieldset id='racIe'></fieldset></dl></div>

        如何获取“数据"来自 xhr.responseText 的字段?

        时间:2023-10-14
      1. <tfoot id='9MiqX'></tfoot>

      2. <small id='9MiqX'></small><noframes id='9MiqX'>

              • <bdo id='9MiqX'></bdo><ul id='9MiqX'></ul>

                <legend id='9MiqX'><style id='9MiqX'><dir id='9MiqX'><q id='9MiqX'></q></dir></style></legend>
              • <i id='9MiqX'><tr id='9MiqX'><dt id='9MiqX'><q id='9MiqX'><span id='9MiqX'><b id='9MiqX'><form id='9MiqX'><ins id='9MiqX'></ins><ul id='9MiqX'></ul><sub id='9MiqX'></sub></form><legend id='9MiqX'></legend><bdo id='9MiqX'><pre id='9MiqX'><center id='9MiqX'></center></pre></bdo></b><th id='9MiqX'></th></span></q></dt></tr></i><div id='9MiqX'><tfoot id='9MiqX'></tfoot><dl id='9MiqX'><fieldset id='9MiqX'></fieldset></dl></div>

                    <tbody id='9MiqX'></tbody>
                1. 本文介绍了如何获取“数据"来自 xhr.responseText 的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有下面给出的 XMLHttpRequest() 函数

                  I have XMLHttpRequest() function given below

                  var searchFriendRequests = function (userid) {
                      var xhr = new XMLHttpRequest();
                      xhr.open('GET', 'http://localhost:6344/api/Registeration/searchFriendrequests?userid=' + userid, false);
                      xhr.setRequestHeader("Content-Type", "text/xml");
                      xhr.onreadystatechange = function () {
                          if (xhr.readyState == 4) {
                              if (xhr.status == 200) {
                                  var data = xhr.responseText;
                              }
                          }
                      };
                      xhr.send(null);
                  }
                  

                  其中 xhr.responseText 将值返回为

                  {
                      "$id": "1",
                      "ContentEncoding": null,
                      "ContentType": null,
                      "Data": [
                          {
                              "$id": "2",
                              "email": "anu@gmail.com"
                          },
                          {
                              "$id": "3",
                              "email": "anu@gmail.com"
                          }
                      ],
                      "JsonRequestBehavior": 1,
                      "MaxJsonLength": null,
                      "RecursionLimit": null
                  }
                  

                  如何从 responseText 中获取 Data 字段?

                  How can I get the Data field from the responseText?

                  推荐答案

                  使用 JSON.parse(),如:

                  var data=xhr.responseText;
                  var jsonResponse = JSON.parse(data);
                  console.log(jsonResponse["Data"]);
                  

                  这篇关于如何获取“数据"来自 xhr.responseText 的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:循环中的 XMLHttpRequest 下一篇:中止 xmlhttprequest

                  相关文章

                  最新文章

                  <i id='RTNhO'><tr id='RTNhO'><dt id='RTNhO'><q id='RTNhO'><span id='RTNhO'><b id='RTNhO'><form id='RTNhO'><ins id='RTNhO'></ins><ul id='RTNhO'></ul><sub id='RTNhO'></sub></form><legend id='RTNhO'></legend><bdo id='RTNhO'><pre id='RTNhO'><center id='RTNhO'></center></pre></bdo></b><th id='RTNhO'></th></span></q></dt></tr></i><div id='RTNhO'><tfoot id='RTNhO'></tfoot><dl id='RTNhO'><fieldset id='RTNhO'></fieldset></dl></div>

                    <tfoot id='RTNhO'></tfoot>

                    • <bdo id='RTNhO'></bdo><ul id='RTNhO'></ul>
                    <legend id='RTNhO'><style id='RTNhO'><dir id='RTNhO'><q id='RTNhO'></q></dir></style></legend>

                    1. <small id='RTNhO'></small><noframes id='RTNhO'>