1. Ajax request
The code format for sending an Ajax request is as follows:
$. Ajax (parameters)
The optional values of the parameters in the method are as follows:
Example:
$ (Document). on ('ajaxcomplete', function (e ){
Var xhr = e. detail. xhr;
Console. log ('request received Med ');
});
3. Get request
Although the Ajax method is powerful. However, the Get or Post method is usually used in projects, which is much easier to use.
Dom7.get method example:
$. Get ('blog-post. Php', {foo: 'bar', id: 5}, function (data ){
Registrant certificate ('.articles'developer.html (data );
Console. log ('load was saved Med ');
});
4. Post request
Dom7.post method example:
$. Post ('auth. Php', {username: 'foo', password: 'bar'}, function (data ){
Registrant certificate ('.login'developer.html (data );
Console. log ('load was saved Med ');
});
5. Obtain JSON data asynchronously.
With Dom7.getJSON, we can use ajax to obtain json data on the server and convert it into an object automatically. Example:
$. GetJSON ('items. Json', function (data ){
Console. log (data );
});