<legend id='E0zJh'><style id='E0zJh'><dir id='E0zJh'><q id='E0zJh'></q></dir></style></legend>

    <tfoot id='E0zJh'></tfoot>
  1. <small id='E0zJh'></small><noframes id='E0zJh'>

      <bdo id='E0zJh'></bdo><ul id='E0zJh'></ul>

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

      如何发送“&amp;"?通过 AJAX 的(和号)字符?

      时间:2023-10-15

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

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

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

                  <tbody id='fFxSU'></tbody>
              1. 本文介绍了如何发送“&amp;"?通过 AJAX 的(和号)字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我想用 JavaScript 的 POST 方法发送一些变量和一个字符串.

                I want to send a few variables and a string with the POST method from JavaScript.

                我从数据库中获取字符串,然后将其发送到 PHP 页面.我正在使用 XMLHttpRequest 对象.

                I get the string from the database, and then send it to a PHP page. I am using an XMLHttpRequest object.

                问题是字符串多次包含字符&,而PHP中的$_POST数组把它看成是多个键.

                The problem is that the string contains the character & a few times, and the $_POST array in PHP sees it like multiple keys.

                我尝试将 & 替换为 &replace() 函数,但它似乎没有做任何事情.

                I tried replacing the & with & with the replace() function, but it doesn't seem to do anything.

                谁能帮忙?

                javascript 代码和字符串如下所示:

                var wysiwyg = dijit.byId("wysiwyg").get("value");
                var wysiwyg_clean = wysiwyg.replace('&','&');
                
                var poststr = "act=save";
                
                poststr+="&titlu="+frm.value.titlu;
                poststr+="&sectiune="+frm.value.sectiune;
                poststr+="&wysiwyg="+wysiwyg_clean;
                poststr+="&id_text="+frm.value.id_text;
                
                xmlhttp.open("POST","lista_ajax.php",true);
                xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                xmlhttp.send(poststr);
                

                字符串是:

                 <span class="style2">&quot;Busola&quot;</span>
                

                推荐答案

                你可以使用 encodeURIComponent().

                它将转义所有不能在 URL 中逐字出现的字符:

                It will escape all the characters that cannot occur verbatim in URLs:

                var wysiwyg_clean = encodeURIComponent(wysiwyg);
                

                在此示例中,与字符 & 将被替换为转义序列 %26,这在 URL 中有效.

                In this example, the ampersand character & will be replaced by the escape sequence %26, which is valid in URLs.

                这篇关于如何发送“&amp;"?通过 AJAX 的(和号)字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:document.write() 覆盖文档? 下一篇:通过 HTTP 将数据从浏览器流式传输到服务器的方

                相关文章

                最新文章

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

              2. <legend id='VC0dW'><style id='VC0dW'><dir id='VC0dW'><q id='VC0dW'></q></dir></style></legend>

                    <tfoot id='VC0dW'></tfoot>
                  1. <small id='VC0dW'></small><noframes id='VC0dW'>