The caching mechanism in IE 11 is preventing Ajax from loading and displaying data

Utilizing Ajax to verify data and display it on the page, alongside implementing varnish cache. The data appears correctly on all web browsers, with the exception of IE 11, unless the varnish cache is disabled.

function checkMyData() {
var surl = 'index.php?eID=thismydata';
if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
    surl += '&hash=' + Math.random();
}
$.ajax({
    type: "GET",
    url: siteurl + surl,
    asynchronous: true,
    data: 'mode=datalist' +
            '&initdatalist=' + initdatalist +
            '&datastr=' + datastr,      
    success: function (answer) {
        var response;
        try {
            response = eval('(' + answer + ')');
        } catch (err) {
            alert('Err: ' + answer);
            return;
        }
        if (initdatalist == 1)
            initdatalist = 0;
        $basic_cont = '<div class="row"><div class="col-md-6 col-md-offset-3"><p class="data-title">' + 
                response.firstmatch + response.otherdata + '</p></div></div>' +
                response.matches;

        $("#thisdaydata").empty();
        $($basic_cont).appendTo("#thisdaydata");
    }
});
}

HTML Output for all browsers (excluding IE 11):

<div id="thisdaydata">
<div class="row">
   <div class="col-md-6 col-md-offset-3">
       <p class="data-title">data here</span></p>
   </div>
</div>

HTML Output for IE 11:

<div id="thisdaydata"></div>

Is this Ajax code not compatible with IE 11?

Answer №1

Internet Explorer has a feature that automatically caches responses from GET requests, unlike other browsers which give you the option to choose whether or not to cache the result. Once IE has successfully made a GET request, it will cease making that AJAX call until the cache expires on that object. You can prevent caching by adding the value cache: false in your ajax code. For more information and alternative methods, check out this informative article and this helpful question.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Retrieving information from an AJAX callback

Is there a way to extract the URLs from PHP data? Here is an example script that may help you achieve this: PHP $query = 'SELECT * FROM picture LIMIT 3'; $result = mysql_query($query); while ($rec = mysql_fetch_array($result, MYSQL_ASSOC)) { ...

Troubleshooting why the Angular innerHTML function is failing to render the specified

I'm encountering this problem where I am receiving a string const str = '<p>Please ensure Process Model diagram represents Functions adequately (boxes that represent an activity or group of activities that produce an outcome):</p>< ...

Switch app engines in real-time based on the URL path with express framework

How can I dynamically set App Engine based on the URL? In my application, I have two render engines available: serverSideRenderEngine & browserRenderEngine If the URL is /home, the app.engine should be set as serverSideRenderEngine If the URL is /l ...

Is there a way to ensure that the elements created by the select form are only generated once?

I have a JavaScript function that dynamically creates paragraph and input elements based on user selection in HTML. However, I am looking to optimize the code so that each element is only created once. Snippet of JavaScript code: function comFunction(sel ...

Exploring the meaning behind RxJS debounce principles

Referencing information found in this source: const debouncedInput = example.debounceTime(5); const subscribe = debouncedInput.subscribe(val => { console.log(`Debounced Input: ${val}`); }); When the first keyup event occurs, will the debouncedI ...

npm socket.io installation failed due to node version being less than 0.10.0

Having trouble installing socket.io on my BeagleBone Black because my system is using Node v0.8.22, but the required version for installation is above 0.10.0. Unfortunately, I am unable to upgrade my Node. /usr/bin/ntpdate -b -s -u pool.ntp.org cd /var/li ...

AngularJS encounters an error message stating, "The data being posted is invalid in syntax according to the client."

Angular post request $http({ method: 'POST', url: '/DineOut/send', contentType:'application/json', dataType:'json&ap ...

Error: Unspecified process.env property when using dotenv and node.js

I'm encountering an issue with the dotenv package. Here's the structure of my application folder: |_app_folder |_app.js |_password.env |_package.json Even though I have installed dotenv, the process.env variables are always u ...

The npm package installation process encountered difficulties in accessing the Chart.Js library

Currently, I am in the process of developing a web application that tracks and logs hours spent on various skills or activities. The data is then presented to the user through a bar graph created using Chart.js. Initially, I was able to display a mock grap ...

React 18 doesn't trigger component re-rendering with redux

In my code, I have implemented a custom hook to handle global data fetching based on user authentication. Here is an example of the hook: const userState = useSelector(state => state.user.state) useEffect(() => { if(userState === "authentic ...

Simulating a PubSub publish functionality

I have been trying to follow the instructions provided in this guide on mocking new Function() with Jest to mock PubSub, but unfortunately I am facing some issues. jest.mock('@google-cloud/pubsub', () => jest.fn()) ... const topic = jest.fn( ...

Get a file from a distinct internal server than the one where the website is operating

I am trying to download a file from an internal server that is separate from the one where the website is hosted. I have attempted various methods such as... <a href="javascript:Start('file://servername/path/filename.txt')> <a href="// ...

What is the best way to optimize my ExpressJS + Sequelize files for proper compatibility with Jest testing framework?

For the past few years, I have been developing an ExpressJS server application for internal use at my workplace. This application serves as a clinical decision support tool utilized in various hospitals. As the application has grown significantly in size, ...

The usage of Arrow Functions within Object Literal Syntax

I can't seem to understand why an arrow function within an object literal is invoked with window as the context for this. Any insights on this would be greatly appreciated. var arrowObject = { name: 'arrowObject', printName: () => { ...

Open the URL in a new tab based on certain conditions

Currently, my page redirects if a specific checkbox is selected and the "submit" button is clicked: if request.Form("myCheckbox") = "on" then response.Redirect("/newPage.asp?txt="staff"") else response.Redirect("/thisPage.asp") end if I ...

Tips for converting a QR code to data URL encoding to include in a JSON response

I created a nodejs function to encode a QR code and I want to return the result back to the caller function in order to create a JSON response. However, for some reason my code is not returning the data response. Can someone please help me figure out what& ...

Is there a way for me to track the number of times the local HTML document has been accessed?

Imagine we have a standalone HTML file that is sent to someone. Is there a way, possibly using third-party services, to track if the document has been opened without the user knowing? I thought about placing a PHP script on a "friendly" server and making ...

Inquiries for Web-Based Applications

As I contemplate coding my very first webapp, I must admit that my skills are somewhere between beginner and intermediate in html, css, js, jquery, node, sql, and mongodb. However, the challenge lies in not knowing how to bring my vision to life. My ulti ...

Tips for choosing a week on a calendar with JavaScript

Here is the code for my calendar: <script> $(document).ready(function() { var events = <?php echo json_encode($data) ?>; $('#calendar').fullCalendar({ header: { left: 'prev,next', center: &apos ...

Unexpectedly, the Discord bot abruptly disconnects without any apparent cause

Hey there! I've encountered an issue with my Discord bot - it keeps disconnecting after a few hours without any apparent cause! This particular bot is designed to regularly ping the Apex Legends game servers to check their status and display the ser ...