日期:2014-05-16 浏览次数:20349 次
<script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> function do_jsonp(){ $.getJSON("http://192.168.0.110:8080/zjres/test.jsp?callback=?", //调用JSONP 数据来源 function(json){ alert(json.length); $('#result').val('My name is: ' + json[0].name); }); } </script> </head> <body> <a href="javascript:do_jsonp();">Click me</a><br /> <textarea id="result" cols="50" rows="3"></textarea> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%String callback=request.getParameter("callback"); %> <% out.print(callback+"([ { name:\"testJohn\"} ,{name:\"testJohn1\"}] )");%>