Analysis of Ajax caching problems in jquery _jquery

Source: Internet
Author: User
The AJAX request for jquery is the default request cache is true, which is turned on, and defaults to False when datatype is script and JSONP. Now I want to read the cache in the browser, because the AJAX request data is very large, request once is enough. But the problem is, in FF, there is no Ajax cache, that is, each time the AJAX request will be triggered, this is not the same as IE. So here's the thing to be aware of, to make a judgment that prevents the Ajax event from triggering.
Copy Code code as follows:

function Ajax_show (apartid,roomclass,sorttile) {
Hx_this_fangxing_num=sorttile;
Huxing_pic_set_color ();
var this_li=$ (' #title_ ' +sorttile);
var cache=this_li.data ("cache");
if (Undefined!=cache) {
var Data_arr =cache.split ('-');
xg_pic_links=data_arr[0];//Cache Record
LAYOUT_PIC_LINKS=DATA_ARR[1];
LAYOUT_BIG_PIC_LINKS=DATA_ARR[2];
PRODUCT_LINKS=DATA_ARR[3];
Xg_pic_deal_array ();
Xg_show_pic (xg_now_pic_id);
}else{
$.ajax ({///JQ cached cache under FF or a new request will be initiated
Type: "POST",
URL: "Index.php?m=content&c=index&a=ajax_all_pic",
Data: "Apartid=123&roomclass=123",
DataType: ' Text ',
Success:function (backdata) {
This_li.data (' cache ', backdata);/cache Record
var Data_arr =backdata.split ('-');
XG_PIC_LINKS=DATA_ARR[0];
LAYOUT_PIC_LINKS=DATA_ARR[1];
LAYOUT_BIG_PIC_LINKS=DATA_ARR[2];
PRODUCT_LINKS=DATA_ARR[3];
Xg_pic_deal_array ();
Xg_show_pic (xg_now_pic_id);
}
});

}
}

Mark by This_li.data (' cache ', backdata)//cache record
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.