What Is Ajax?
Ajax = Asynchronous JavaScript and XML.
Ajax is a technology for creating fast dynamic web pages.
Ajax allows asynchronous updates on webpages by exchanging a small amount of data with the server in the background. This means that it is possible to update part of the webpage without reloading the whole page.
Ajax and jquery
Jquery provides a rich library of functions (methods) for Ajax development.
Using jquery Ajax and http get and http post, you can request txt, HTML, XML, or JSON from a remote server.
In addition, you can directly load remote data into the selected HTML element of the webpage!
Jquery load function
Jquery's load function is a simple (but powerful) Ajax function. Its syntax is as follows:
$ (Selector). Load (URL, Data, callback)
Please useSelectorTo define the HTML elements to be changed, useURLParametersTo specify the web address of the data.
Only when you want to send data to the serverDataParameters. You must useCallbackParameters.
Low level Ajax
$. Ajax (options)Is the syntax of low-level Ajax functions.
$. Ajax provides more functions than high-level functions, but it is also more difficult to use.
OptionThe parameter is set to name | value pair, which defines URL data, password, data type, filter, Character Set, timeout, and error functions.
Jquery Ajax request
Request |
Description |
$ (Selector). Load (URL, Data, callback) |
Load remote data to the selected Element |
$. Ajax (options) |
Load remote data to the XMLHTTPRequest object |
$. Get (URL, Data, callback, type) |
Use http get to load Remote Data |
$. Post (URL, Data, callback, type) |
Use http post to load Remote Data |
$. Getjson (URL, Data, callback) |
Use http get to load remote JSON data |
$. Getscript (URL, callback) |
Load and execute remote JavaScript files |
(URL) URL (address) of the loaded data)
(Data) Key/value object of the data sent to the server
(Callback) When the data is loaded, the executed Function
(Type) Type of the returned data (HTML, XML, JSON, jasonp, script, text)
(Options) All key/value pair options of the complete Ajax request