开发者

Read a txt file from jQuery (304 Not Modified)

I am tryi开发者_运维问答ng to load a text file via a jQuery ajax call $.get the issue i am receiving is a 304 Not Modified in console.

I am trying to get the data from the text file which will be local to the document it is called from. In this instance the text file will just contain a single word master. The aim for loading the data is to call a global variable that will trigger certain events based on the text in the text file.

Here is the code in question:

var sv_settings;
$.get('settings.txt', function(data) {
    sv_settings = data;
});

What am i missing? Why is my browser returning 304 Not Modified ?


Try tricking the cache:

var sv_settings;
$.get('settings.txt?v='+Math.random(), function(data) {
    sv_settings = data;
});

This will make your browser think that settings.txt?v=0.234234 is a different file from settings.txt?v=0.111222 which we know is not the case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜