日期:2014-05-20 浏览次数:21129 次
<script type="text/javascript" src="js/json.js"></script> <script type="text/javascript" src="prototype.js"></script> <script type="text/javascript"> function sendRequest(){ var url="/JSON/JSONTest1"; alert("json"); var mailAjax=new Ajax.Request( url, { method:'get', onComplete:jsonResponse } ); alert("json"); } function jsonResponse(originalRequest){ alert(originalRequest.responseText); var myobj=originalRequest.responseText.parseJSON(); alert(myobj.name); } </script>
PrintWriter out=resp.getWriter(); out.print("{\"name\":\"liuyong\",\"age\":21}"); out.flush(); out.close();