jquery和servlet如何传递JSON数组?
例 3.7(AjaxJsonArray.jsp)
<html>
<head>
<script src="jquery.js"></script>
<script type="text/javascript">
function getP(id) {undefined
$.getJSON("jqueryservlet37", {undefined
id : id
}, function(arr) {undefined
for ( var i = 0; i < arr.length; i++) {undefined
var obj = arr[i];
for ( var pro in obj) {undefined
document.getElementById(pro).innerHTML = obj[pro];
}
}
/* document.getElementById(pro).innerHTML = obj[pro];和下一句一样。
$("#"+pro).html(obj[pro]);
*/
})
}
</script>
</head>
<body>
<table width="340" border="1">
<tr>
<td id="1" οnclick="getP('1')">点这1</td>
<td id="2" οnclick="getP('2')">点这2</td>
</tr>
</table>
更多内容请见原文,文章转载自:https://blog.csdn.net/qq_44594371/article/details/103063483