0

I have an login.dxview file

    <div id="divLoginNews">
        <div data-bind="html:newsContent" style="color:white;"></div>
    </div>

Above div block shows news.html file content. news.html file is at server side. below javascript code reads news.html

$.ajax({
    url: oClientInfo.sRootAddress + '/Information/news.html',
    error: function () {
    },
    success: function (data) {
        viewModel.newsContent(data);
    }
});

issue is if I update the news.html content on page reload, the content is not updated in browser. I understand that in above url, if I get the file modified date as url query string, it should solve issue. I want to syntax for the same. I could not find it till now. (I want to re-load file from server, only when it was changed.)

1 Answer 1

1

You can add parameter like current time on the URL to avoid caching

var today = new Date();
var time = today.getHours() + today.getMinutes() + today.getSeconds();

$.ajax({
    url: oClientInfo.sRootAddress + '/Information/news.html?time=' + time,
    error: function () {
    },
    success: function (data) {
        viewModel.newsContent(data);
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

This code will load file everytime as time will be different everytime. If we can get file modified datetime, that is best I think. But how can we do that, if you know syntax please share.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.