Skip to content

Instantly share code, notes, and snippets.

@leedohyung-dba
Last active September 17, 2016 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leedohyung-dba/173be611dd0d03bff3c182c8cecde18c to your computer and use it in GitHub Desktop.
Save leedohyung-dba/173be611dd0d03bff3c182c8cecde18c to your computer and use it in GitHub Desktop.
jQuery.ajaxにCacheが残って困ったら設定 ref: http://qiita.com/leedohyung-dba/items/2cfd683c65aeb7c1108d
{
"head": "test_a"
}
var ajaxCacheTest = {
jsonFiles: {1:'1_test',
2:'2_test',
3:'3_test',
4:'none_test'},
getData: function(fileName) {
$.ajax({
type: 'GET',
url: 'ajaxTestJsonFiles/'+fileName+".json",
dataType: 'json',
success: (res) => {
console.log(res.head);
},
error: (err) => {
// error
}
});
}
}
$(function() {
_.forOwn(ajaxCacheTest.jsonFiles, function(fileName, key) {
ajaxCacheTest.getData(fileName);
});
$("#reload").on('click', function() {
_.forOwn(ajaxCacheTest.jsonFiles, function(fileName, key) {
ajaxCacheTest.getData(fileName);
});
});
});
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment