AJAX = asynchronous JavaScript and XML.
AJAX is a technique for creating fast, Dynamic Web pages.
AJAX allows Web pages to be updated asynchronously by exchanging small amounts of data in the background with the server. This means that it is possible to update part of a Web page without overloading the entire page.
There are many methods of Ajax submissions provided in the jquery scripting library, but the main methods are $.get (), $.post (), $.ajax (). where $.ajax () is the underlying implementation of the first two methods and can provide more properties and parameter settings than the previous one, it is recommended to use the $.ajax () method if advanced settings are required.
"Reproduced use, please specify the source:http://blog.csdn.net/mahoking"
Learn $.get () method
Learn $.post () method
Learn $.ajax () method
The
$.post () Method
Post () method loads data from the server over an HTTP POST request.
Syntax:
$.post (url,data,success (data, Textstatus, JQXHR), DataType)
Comment:
url required. Specifies which URL to send the request to. The
data is optional. The map or string value. Specifies the data that is sent to the server along with the request.
Success (data, Textstatus, JQXHR) Optional. The callback function to execute when the request succeeds.
datatype Optional. Specifies the data type of the expected server response. The
performs smart judgments by default (XML, JSON, script, text, HTML, and so on).
demo case:
1, Create Web project Jqueryajax.
2, create js/jquery file directory under Webroot, add Jquery-2.1.1.js
3, create servlet (Ajaxpostservlet). As follows:
public class Ajaxpostservlet extends HttpServlet {public void doget (HttpServletRequest request, HttpServletResponse Response) throws Servletexception, IOException {retdata (Request, Response, "GET");} public void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException { Retdata (Request, Response, "POST");} /** * Provide return data to request * @param request * @param response * @param method * @throws ioexception */private void Retdata (Httpservle Trequest request, HttpServletResponse Response,string method) throws ioexception{string UserName = Request.getparameter ("UserName"); String age = Request.getparameter ("Age"); PrintWriter out = Response.getwriter (); Out.print (method+ ": Username=" +username+ ", age=" +age); Out.flush ();}}
4, create jquery_ajax_method_post.jsp.
<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%><%string path = Request.getcontextpath () ; String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";%> <! DOCTYPE html>5. Deploy the project to Tomcat and test it.
"Reproduced use, please specify the source: http://blog.csdn.net/mahoking "
JQuery AJAX $.post () method