标签:style http java os io for cti html
经过的项目大大小小也有非常多的了,印象中很多框架低层封装的方法都是在ajax()方法的基础上进行扩展的。ajax方法可以说是jQuery提供的各式各样的ajax相关方法的鼻祖,所有其他的比如load,get,post,getScript,getJson方法都是扩展于jQuery.ajax方法。前端页面的代码:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script type="text/javascript" src="jquery-1.8.3.js"></script> <script type="text/javascript"> $(function(){ $("#getContent").click(function(){ $.ajax({ url:"test", type:"get", timeout:2000, data:{name:"czz",address:"address"}, dataType:'html', beforeSend:function(){alert('beforeSend');}, complete:function(){alert('complete');}, success:function(data,status){alert(data);}, error:function(){alert('error');}, global:false }); }); }); </script> </head> <body> <div id="showText"><span>He who hesitates is lost.</span></div> <input type="button" id="getContent" value="getAjax"> </body> </html>
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String name = req.getParameter("name"); String address = req.getParameter("address"); StringBuffer sb = new StringBuffer(""); sb.append("{\"name\":\"") .append(name) .append("_czz\",\"address\":\"") .append(address) .append("_czz\"}"); resp.getWriter().print(sb.toString()); }
jQUery_review之jQuery的终极ajax方法$.ajax(),布布扣,bubuko.com
jQUery_review之jQuery的终极ajax方法$.ajax()
标签:style http java os io for cti html
原文地址:http://blog.csdn.net/ziwen00/article/details/38194397