The following is the method of using AJAX that I have compiled for you. Interested students can take a look.
HTTPS
"/jsontest/randomdata/" // there was a missing trailing /// i.e. // was going to https://larsendt.com/jsontest/randomdata/?ymax=500&count=32&t=0.96041791105086431234
GET request
新建网页 ajax之get形式请求
用户名:
密码:
12345678910111213141516171819202122232425262728293031323334353637
POST request
新建网页 ajax之post形式请求
用户名:
密码:
123456789101112131415161718192021222324252627282930313233343536373839404142
FormDate collects form data
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
AJAX cross-domain
//放在被访问资源上 12
jasonP
//在客户端定义函数,在服务端定义调用函数和传入参数,请求时传入调用参数内容,服务端就用客户端传入的函数名为调用函数名(可变函数); // https://xxx.cc.com/xx.php?param=xxx&function_name=function_name//百度标准接口 https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=法国大选&cb=demo12345
JQUERY AJAX
Syntax :
$.get(url,data,function(),dataType)
url: Requested file.
data: Pass data.
function(responseText, statusText,xhr): Return function.
responseText: Returned text.
statusText: The returned status value.
status contains the status of the request
("success", "notmodified", "error", "timeout", "parsererror")
xhr: XMLHttpRequest() request object.
datatype:
"xml" - an XML document
"html" - HTML as plain text
"text" - a plain text string
"script" - runs the response in JavaScript and Returns
"json" as plain text - runs the response as JSON and returns it as a JavaScript object
"jsonp" - loads a JSON chunk using JSONP, which will add a "?callback=?" to the URL to specify the callback
.get(),.get(),.post() //post is the same as get parameters
JQuery Collapse 用户名:
密码:
1234567891011121314151617181920212223242526272829303132333435363738394041
$.ajax()
The above is what I compiled I hope everyone’s tips on how to use AJAX will be helpful to you in the future.
Related articles:
Detailed explanation of the steps for jQuery ajax to call WCF service
jQuery AJAX timeout timeout emergency handling method
JQuery AJAX implementation file download
The above is the detailed content of Detailed analysis of how to use AJAX (code pasted). For more information, please follow other related articles on the PHP Chinese website!