问题一:<span style="display:none;">  经过 ajax 传给 php  为什么 变成了 <span style="\&quot;display:none;\&quot;">   ???\&quot; 是怎么回事?
问题二:怎样替换掉 \&quot; 呢?$a='<span style="\&quot;display:none;\&quot;">'; 
$a = str_replace("\&quot;",'',$a);   
echo $a; 
不行???

解决方案 »

  1.   

    传递的字符串上加上 encodeURI
    encodeURI(str)
      

  2.   

    &quot; 是双引号的html编码,至于为什么会被转换这就要查你的ajax代码了
      

  3.   

    <script type="text/javascript">
    $(document).ready( function() {
    $('.test').click(function(){
     
    var thishtml=$(this).html();
     
    alert(thishtml); 
    $.post(
     './test.php', 
     '&thishtml=' + thishtml,
     function(msg){
     alert(msg)
     }
    ); 
    });
    });
     </script>
    <span  class="test">
    <span style="display:none;">text1</span>text2
    </span><?php
    //test.php 
    echo $_POST['thishtml'];
    ?>
    就这样,没错啊
      

  4.   

    为什么发送时会转换成这个呢?应该用firebug 的监控,
    看楼主的说法post 过去的值 已经被转换过了,
    那应该是js 脚本实现ajax 时,做了点多余的操作。把那里看看,希望能解决。
      

  5.   

    能否 先 想法 删除 这个 讨厌的 符号?$a='<span style="\&quot;display:none;\&quot;">'; 
    $a = str_replace("\&quot;",'',$a);   
    echo $a; 还有其他方法么?
      

  6.   

    <span style="display:none;"> 
    用单引号,或者双单引号,你测试下吧。我也不知道用哪个。
    什么都得试试嘛。