Example of DOM7 Library Ajax, Get, and Post data requests in Framework7

Source: Internet
Author: User
Tags json

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 );
});

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.