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

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

    • <bdo id='xkL7u'></bdo><ul id='xkL7u'></ul>
  1. <legend id='xkL7u'><style id='xkL7u'><dir id='xkL7u'><q id='xkL7u'></q></dir></style></legend>

    1. responseText - XMLHttpRequest

      时间:2023-10-13

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

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

      • <tfoot id='jBd5S'></tfoot>

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

                  <tbody id='jBd5S'></tbody>
              • 本文介绍了responseText - XMLHttpRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                在我的代码中 responseText 不起作用.它应该显示,在文本框中输入的文本+:您的请求已被 syam 看到"

                <html><head id="Head1" runat="server"><标题></标题><脚本类型="文本/javascript">var xmlHttpRequest;函数 sSignature(str) {xmlHttpRequest = 新的 XMLHttpRequest();xmlHttpRequest.onreadystatechange = function() {如果(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200){document.getElementById("target").innerHTML = xmlHttpRequest.responseText;}}xmlHttpRequest.open("GET", "AjaxResponse.aspx?q=" + str, true);xmlHttpRequest.send();}</脚本></头><身体><form id="form1" runat="server">

                输入一个字符串:<input type="text" id="textbox" onkeyup="sSignature(this.value)"/><span id="target">这里的文字应该改变</span></div></表格></身体></html>

                在代码隐藏页面中,在 page_load() 中

                string sRequest = Request.QueryString["q"];var sResponse = sRequest+ " :您的请求已被 syam 看到";Response.Write(sResponse);

                解决方案

                我相信错误出在您的 onreadystatechangedhandler 中.它将接收一个 event 参数,其中 target 属性指向 XHR 实例.

                尝试用这个换掉它:

                xmlHttpRequest.onreadystatechange = 函数(事件){var xhr = event.target;如果(xhr.readyState === 4 && xhr.status === 200){document.getElementById("target").innerHTML = xhr.responseText}};

                in my code responseText is not working. It is supposed to display, text entered in the text box +" :Your request has been seen by syam"

                <html>
                    <head id="Head1" runat="server">
                    <title></title>
                        <script type="text/javascript">
                            var xmlHttpRequest;
                            function sSignature(str) {
                
                                xmlHttpRequest = new XMLHttpRequest();
                                xmlHttpRequest.onreadystatechange = function() {
                                    if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {                
                                        document.getElementById("target").innerHTML =    xmlHttpRequest.responseText;
                                    }
                                }
                                xmlHttpRequest.open("GET", "AjaxResponse.aspx?q=" + str, true);
                                xmlHttpRequest.send();
                            }
                        </script>
                    </head>
                    <body>
                        <form id="form1" runat="server">
                            <div>
                            enter a string :<input type="text" id="textbox" onkeyup="sSignature(this.value)"/>
                            <span id="target">text should change here</span>
                            </div>
                        </form>
                    </body>
                </html> 
                

                In the code-behind page, in page_load()

                string sRequest = Request.QueryString["q"];
                var sResponse = sRequest+ " :Your request has been seen by syam";
                Response.Write(sResponse);
                

                解决方案

                I believe the error is in your onreadystatechangedhandler. It will receive an event param, in which the target property points to the XHR-instance.

                Try swapping it out with this:

                xmlHttpRequest.onreadystatechange = function (event) {
                    var xhr = event.target;
                
                    if (xhr.readyState === 4 && xhr.status === 200) {
                        document.getElementById("target").innerHTML = xhr.responseText
                    }
                };
                

                这篇关于responseText - XMLHttpRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Access-Control-Allow-Origin 和 CORS 背后的概念是什么 下一篇:跨域进行 JavaScript 调用

                相关文章

                最新文章

              • <tfoot id='Tx7lq'></tfoot>

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

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

                  1. <legend id='Tx7lq'><style id='Tx7lq'><dir id='Tx7lq'><q id='Tx7lq'></q></dir></style></legend>