A. What is Ajax?
Ajax is "Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML), a Web development technology that creates interactive Web applications. You can communicate with the server without refreshing the page. 1.XMLHttpRequest
1 Open ("Method", "url") establish a call to the server
2 Send (content) request to the server
3) onreadystatechange Each state change triggers this event, usually calling a function
4 readystate Request Status: 0-uninitialized, 1-loading, 2-already loaded, 3-interactive, 4-complete
5) ResponseTest: Server response
6 Status: Server's HTTP State Code instance Practice:
Realization click on the name Link Display link to the text content to the original page, do not jump page.
huan.html Content
<! DOCTYPE html>
ming.html Content
<! DOCTYPE html>
yun.html Content
<! DOCTYPE html>
1. Implement with native method: index_1.jsp code:
<%--Created by the IntelliJ idea. user:pc date:17-4-21 Time: PM 12:10 To change this template use File | Settings |
File Templates. --%> <%@ page contenttype= "Text/html;charset=utf-8" language= "java"%>
Results:
2.load Method:
Load (Url,[data],[callback]) inserts remote HTML into the DOM
URL: Request the URL address of the page
Data: Sending to Key/value
Callback: callback function at completion of request 2.load method implementation: index_1.jsp code:
<%--Created by the IntelliJ idea. user:pc date:17-4-21 Time: PM 12:10 To change this template use File | Settings |
File Templates. --%> <%@ page contenttype= "Text/html;charset=utf-8" language= "java"%>
2. Get. Get. Post method:
2.get method. Post method implementation: INDEX_1.JSP code:
<%--Created by the IntelliJ idea. user:pc date:17-4-21 Time: PM 12:10 To change this template use File | Settings |
File Templates. --%> <%@ page contenttype= "Text/html;charset=utf-8" language= "java"%>
article: javaee– Learning Notes