日期:2014-05-16 浏览次数:20420 次
<%@ page language="java" contentType="text/html; charset=UTF-8"%> <html> <head> <title>ajax jsonp test</title> <script src="jquery/jquery-1.3.2.min.js" type="text/javascript"> </script> <script type="text/javascript"> $(document).ready(function(){ $("#button").click(function(){ $.ajax({ data:"?callback=?", url: 'http://192.168.1.170/resp.jsp', dataType:'jsonp', success:function(json){ $("#show").html(json); } }); }); }); </script> </head> <body> <form id="form1" name="form1" method="post"> <INPUT TYPE="button" value="提交" id="button"/> </form> <div id="show"> </div> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String callback = request.getParameter("callback"); String resp = "\"helloworld!\""; out.print(callback+"("+resp+")"); %>