Home >Web Front-end >JS Tutorial >Parsing ajax caching issues in jquery_jquery

Parsing ajax caching issues in jquery_jquery

WBOY
WBOYOriginal
2016-05-16 17:08:19924browse

The default request cache of jquery's ajax request is true, that is, it is turned on. When the dataType is script and jsonp, the default is false. Now I have to read the cache in the browser, because the data requested by ajax is large, and one request is enough. But here comes the problem. In FF, there is no ajax cache, that is, an ajax request will be triggered every time, which is different from IE. So you have to pay attention here, make a judgment, and prevent the ajax event from being triggered.

Copy code The code is 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{
                                                                                                         A new request will still be initiated next
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);                                                               ('cache',backdata);//Cache records , to mark
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn