Last active
September 17, 2016 20:28
-
-
Save leedohyung-dba/173be611dd0d03bff3c182c8cecde18c to your computer and use it in GitHub Desktop.
jQuery.ajaxにCacheが残って困ったら設定 ref: http://qiita.com/leedohyung-dba/items/2cfd683c65aeb7c1108d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"head": "test_a" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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