A simple understanding of the differences between AJAX get and post and web offline applications

Source: Internet
Author: User

1.get method is shown, after the URL will be followed by parameters, security is not good, but the higher performance of the Post method is implicit, high security. 2.get fetch or send data size is limited, generally less than 1KB post fetch or send data size unrestricted, generally 2m3.get way to take data to use QueryString Post method to take data to use Request.Form although both have a unified re Quest methods, but this affects efficiency, as little as possible. 4.get method will cache data post mode never cache data 5.Jquery implementation Ajax:

$.ajax ({
URL: ' Servicehandler.ashx ',
Data: [{name: ' key ', value: ' Download '}],
DataType: ' JSON ',
Type: ' Post ',//or in Get mode
Cache:false,
Async:false,
Error:function (e) {
},
Success:function (data) {
Deposit Storage
$.each (data. Menu, function (i, n) {
Localstorage.setitem ("M" + N.number, Json.stringify (n));
});
}
});

Xpos Project Experience Record:

1. Apply HTML5&CSS3 Pure foreground technology to realize the function of Web local storage and offline application.
2. Local storage mechanisms are now supported in mainstream browsers such as Chrome,safri,firefox,ie 11 or more Localstorage
Window.localStorage.setItem (",")
Window.localStorage.setItem (",")
3.web Offline application mechanism:
A. On the server that publishes the Web, add a file with the suffix. AppCache (for example, Xpos.appcache) to add the content to be cached in the file
CACHE MANIFEST
#要缓存的内容
Main.html
Javascripts/xpos.order.js
NETWORK
#不缓存的内容
B. On the IIS server, double-click the MIME types icon on the home page, then pop up the Add MIME Types dialog box, fill in ". AppCache" at extension, and fill in "Text/cache-manifest" at MIME
C. write in the homepage D. Every time the site updates, be sure to modify the Xpos.appcache file, you can add the updated version, because the cache file update mechanism is based on the update of the Xpos.appcache file to determine whether the site is updated.
E. Cache of various listener events:

var appCache = Window.applicationcache;

Window.addeventlistener (' online ', function () {appcache.update (); });

    appcache.addeventlistener (' Cached ', function () {   });    Appcache.addeventlistener (' Checking ', function () {   });    Appcache.addeventlistener (' Downloading ', function () {   });    Appcache.addeventlistener (' Error ', function () {   });     appcache.addeventlistener (' Noupdate ', function () {   });    Appcache.addeventlistener (' Updateready ', function () {          if ( Confirm (' Server Web site has been updated, is it updated to local? ') {            window.location.reload ();            }                Appcache.swapcache ();              dataoperator.downloaddata ();           dataoperator.showdata ();         3); During the development process, data interaction with WCF through Ajax is often the first or the first few times the data is loaded successfully. Failed to load later. Find out why, experience is as follows:
A. Because of the web off-line caching mechanism enabled, every time Ajax loads the data from the local cache file, the Ajax get mode is used, because the Get mode is cached, so it does not re-request data to the server, causing the data load to fail.
B. After changing to Ajax post, the data never cache, so each time the site is refreshed, the data is requested from the service.

A simple understanding of the differences between AJAX get and post and web offline applications

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.