How to use Ajax requests

醉折花枝作酒筹
Release: 2021-04-22 09:33:08
forward
3099 people have browsed it

This article will give you a detailed introduction to the Ajax request method. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to use Ajax requests

AJAX stands for "Asynchronous Javascript And XML" (Asynchronous JavaScript and XML), which refers to a web development technology for creatinginteractiveweb applications.

AJAX is a browser that initiates a request through jsasynchronouslyto achievelocal updateof the page. For partial updates requested by Ajax, the browseraddress barwill not change, and partial updates will not discard the content of the original page.

NativeAJAXExample of request

Copy after login

AJAXRequest in jQuery

How to use Ajax requests

Copy after login

How to use Ajax requests

// ajax--get请求 $("#getBtn").click(function(){ $.get("http://localhost:8080/json_Ajax_i18n/ajaxServlet","action=jQueryGet",function (data) { alert("服务器返回的数据是:" + data); },"json"); }); // ajax--post请求 $("#postBtn").click(function(){ // post请求 $.post("http://localhost:8080/json_Ajax_i18n/ajaxServlet","action=jQueryPost",function (data) { alert("服务器返回的数据是:" + data); },"json"); });
Copy after login

How to use Ajax requests

// ajax--getJson请求 $("#getJSONBtn").click(function(){ // 调用 $.getJSON("http://localhost:8080/json_Ajax_i18n/ajaxServlet","action=jQueryPost",function (data) { alert("服务器返回的数据是:" + data); }); });
Copy after login

Form serializationserialize()You can get the contents of all form items in the form and use ## Concatenate them in the form of #name=value&name=value.

// ajax请求 $("#submit").click(function(){ // 把参数序列化 //$("#form01").serialize(); $.getJSON("http://localhost:8080/json_Ajax_i18n/ajaxServlet","action=jQuerySerialize&" + $("#form01").serialize(),function (data) { }); });
Copy after login
[Recommended learning:

javascript advanced tutorial]

The above is the detailed content of How to use Ajax requests. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!