js如何等分post数据?
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function split_code(part_len){
var body_code= $("body").html();
var arr=[];
//怎样切割body_code,每一份按part_len参数的长度(如5个字节)来等分,放进arr里面?
//因为用ajax post这个网页代码,如果太大,就会post失败,我想切开来post。
......
for(var i in arr){
alert(arr[i]);
}

</script>
</head><body>
<div class="box">
hello world
</div>
<button onclick="split_code(5)">split</button>
</body>

解决方案 »

  1.   

    字符串截取  array.slice 函数
      

  2.   

    你就用substr进行分就可以了啊
      

  3.   

    额 是substr, 看来我该洗洗睡了。。
      

  4.   

    post方法貌似没有大小限制 不过服务器会有限制
      

  5.   

    body_code.substr(start [, length ]) 
    body_code.substring(start,stop) 
    均可以
      

  6.   

    substring 
    不过html长是不是因为参数太多啊?
    可以考虑把这些参数放在一个对象里传递更好一些