你好,帮你看了下,看是不是你要的结果
function compression(str){if(str.length == 0){
return 0
}
var len = str.length
var str2=""
var i=0
var num=1
while(i<len){
if(str.charAt(i)==str.charAt(i+1)){
num++
}else{
str2+=num
str2+=str.charAt(i)
num = 1
}
i++
}
return str2
}
先说明:a1,a2,a3,a4,a5,在返回的字符串中应该加",否则js会报错.除非在你的环境里,a1,...a5是已经定义的变量.
以下是使用代码.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function handler() {
var result = '[{"aa":"a1","bb":"223","cc":"334","dd":"423","ee":0},{"aa":"a2","bb":"2d2","cc":"3343","dd":"44e","ee":0},{"aa":"a3","bb":"2223","cc":"3xx","dd":"443","ee":0},{"aa":"a4","bb":"225","cc":"3a3","dd":"444","ee":0},{"aa":"a5","bb":"2f2","cc":"3g3","dd":"44w","ee":0}]'
//这里演示的是服务器返回的数据,字符串形式.这方法在回调函数中使用.在实例使用时,result应该替换为服务器返回的数据.
var resultjson = eval(result)
var div = document.getElementById("info")
for (var i = 0i <resultjson.lengthi++) {
div.innerHTML += resultjson[i].aa
if (i <resultjson.length - 1) {
div.innerHTML += ","
}
}
}
window.onload = handler
</script>
</head>
<body>
<div id="info">
</div>
</body>
</html>
has no method 'submit' 是说jquery.easyui.min.js里面没得“submit“这个方法,是否是因为这个”submit“方法是在另外的js里面,而你没有引用。你把你的源码放出来吧。