<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>serialise</title>
     <script src="jquery.js" type="text/javascript"></script>
</head>
<body>
    <form >
        <input type="text" name="a" value="安安" />
        <input type="hidden" name="b" value="abc">

    </form>
    <script type="text/javascript">
        $(function(){
            var formStr=$('#formId').serialize();
            //序列化中文时之所以乱码是因为.serialize()调用了encodeURLComponent方法将数据编码了
            //原因:.serialize()自动调用了encodeURIComponent方法将数据编码了   
            //解决方法:调用decodeURIComponent(XXX,true);将数据解码    
            params = decodeURIComponent(formStr,true); //关键点
            alert(formStr+'\n'+params);
            $.ajax({
                'type':'post',
                'url':'c.php',
                'data':formStr,
                success:function(msg){
                    alert(msg);
                }
            })
        })
    </script>
</body>
</html>
<?php
 $strA=$_POST['a'];
 $strB=$_POST['b'];
 echo $strA."____".$strB;

 

相关文章:

  • 2022-02-24
  • 2021-08-12
  • 2021-12-10
  • 2021-12-10
  • 2021-10-18
  • 2022-01-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-28
  • 2021-10-08
  • 2022-12-23
  • 2021-05-17
  • 2021-05-23
相关资源
相似解决方案