jquery encapsulates some ajax request methods, which is very practical.
For example,
.ajaxComplete() - when the request is completed
.ajaxError() - when the request fails
.ajaxSend() ——Attach a function to execute when the Ajax request is sent
.ajaxStart()——when the request starts,
.ajaxStop()——when the request ends
.ajaxSuccess()——When the request is successful
.load()——Load data from the server and replace the returned HTML into the selected element
jQuery.post() - Use HTTP POST request to load server-side data
.serialize() - Encode the set of form elements into a string for submission
.serializeArray() - Encode the set of form elements into an array of key-value pairs
jQuery.param() - Create a serialized array or object such that Suitable for a URL query string or Ajax request
jQuery.getScript() - load a js file from the server and then execute it
jQuery.getJSON( )——Load JSON-encoded data from the server
jQuery.get()——Load data from the server Simply two points
1. .ajaxStart() and .ajaxStop()
First
Load the content in xixi.html into the element with class result
Finally
执行顺序代码中已经标出
如果请求过程中出现什么错误,比如说文件不存在等,就会执行.ajaxError()中的方法而不是.ajaxSuccess()中的。
以前总是对ajax认识很乱,现在有个全面的认识,总结一下,希望共同学习,另外请求中的方式是HTTP GET还是HTTP POST也是值得研究的。
jquery中介绍ajax的地址ajax的使用