JSON接收值的问题??
var xmlhttp;
function showData(){
var type = "show";
try{
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
}catch(e){
try{
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}catch(e){
try{
xmlhttp = new XMLHttpRequest();
}catch(e){}
}
}
xmlhttp.onreadystatechange=function(){
if (4==xmlhttp.readyState){
if (200==xmlhttp.status){
var data;
alert('ok'); //这句都执行了,证明ajax没有问题
alert(JSON.parse(xmlHttp.responseText));//这出出了问题,
// 提示 Line:105
// Char:13
// Code:0
// Error:例外被抛出且未被接住
//我的json.js 已导入了。这是怎么回事啊。
}else{
alert("error");
}
}
}
xmlhttp.open("post", "pool");
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.send("type="+type);
}
还有一个问题,我在servlet中遍历数据库,并通过jsonObj.put("",""));存入json对象中了,可怎么才能全部传回来啊。
我用out.println(jsonObj.toString());可只是传回来最后一条记录。。??
希望高手们帮忙吧。1