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

Effortless AJAX autorefresh feature displays only the most recent entry!

Just diving into PHP and I am working on creating a forum for users to ask questions. I've implemented ajax to auto refresh the page, but it's causing some issues... Specifically, when I set the div where the most recent question is displayed to ...

Ways to attach the close event to the jquery script

Hello, I'm having trouble reloading the parent page when the close button is clicked on a modal dialog. Here's my code snippet: //customer edit start $( ".modal-customeredit" ).click(function() { var myGroupId = $(this).attr('data- ...

Leveraging the power of recursive ajax requests in combination with PHP to dynamically

+----------------------+ | item1 | item2 | result | +----------------------+ | .... | .... |  ....  | +----------------------+ | .... | .... |  ....  | +----------------------+ | .... | .... |  .... ...

struggling to send variables to jade templates with coffeescript and express.js

As a newcomer to node and express, I am currently building the front end of an application that utilizes jade as its templating engine. Despite extensive searching online and within this community, I have not been able to find a solution to a particular is ...

The 'palette' property is not found on the Type 'Theme' within the MUI Property

Having some trouble with MUI and TypeScript. I keep encountering this error message: Property 'palette' does not exist on type 'Theme'.ts(2339) Check out the code snippet below: const StyledTextField = styled(TextField)(({ theme }) = ...

Is there a way to remove a pseudo element in CSS using Internet Explorer

I've been struggling to make some pseudo elements work in Internet Explorer, but it seems like I can't get it to function as intended. It's as if IE is ignoring the CSS rules that I have set up for these elements, and it's quite frustr ...

AngularJS is throwing an error because the term "grunt" has not

Today is the day I embark on my journey with Grunt for testing my JavaScript code. All the necessary grunt modules have been successfully installed and are documented in a json file called package.json. { "name": "LarissaCity", "private": true, ...

Tips for extracting an XML value from an API

I'm attempting to showcase a value retrieved from an API (specifically used by PRTG software to extract information). Here is the link to the API: The API provides an XML file structured like this: <?xml version="1.0" encoding="UTF-8"?> <ch ...

The requested module cannot be located, were you referring to "js" instead?

I am currently developing a React application using webpack and typescript. I have integrated the dependency react-financial-charts into my project, and it is properly specified in the package.json. Inside the node_modules directory, there are two folders ...

I would like to inquire about the process of accessing profile information on a website through the LinkedIn API

Do you know how I can use the latest LinkedIn JavaScript API with OAuth 2.0 to retrieve my own profile details for a website? The goal is to automatically update the website using my linked profile information. I have attempted the following: api_key: ...

Persistent button positioned at the bottom of the page, remaining visible even when scrolling to the very end of the content

I am looking to add a floating button that remains in the same position relative to the content until the window is scrolled to a certain point, after which it sticks to the end of the content. In simple terms, I want the element to act as 'relative& ...

The iron-session package does not export the path ./next/dist from the package

I am encountering an issue while using iron-session. Below is the code snippet causing the error: import { withIronSessionSsr } from 'iron-session/next/dist'; ... export const getServerSideProps = withIronSessionSsr(async function ({ req, r ...

What could be causing the HTML5 canvas not to show up on the screen?

<!doctype html> <html> <head> <title>Canvas test</title> </head> <body> <script type="text/javascript"> c = getElementById('canvas'); ctx = c.getContext("2d")' ctx.fillRect(10,10,10,10); </s ...

View cards from a restricted Trello board without requiring visitors to have a Trello account or to authorize through a popup

I have a company with ongoing projects listed on a private Trello board. We are interested in showcasing these projects on our website in real-time by connecting to the board. After implementing this example, I can successfully retrieve and display the ca ...

What is the best way to send a string parameter from an Angular UI to a Node.js backend?

My goal is to transfer a string value from an Angular UI to a Node.js backend API, which will then search in MongoDB using the provided string value as shown below. I am attempting to receive input in enteredValue and pass it on to the http.get call as pa ...

Using the Javascript function getElementById to retrieve user input for passing a RSS FeedURL

I've been working on creating a basic form where users can input a Feed URL and see the contents displayed on the HTML page. For testing purposes, I have used "https://jquery-plugins.net/rss" as the feedUrl, and it has been functioning normally. This ...

Tips on aligning a span element at the center of an image without losing its mouseover

<div class="pic"> <img src="image.jpg" height="250"/> <span class="text" style="display:none">text here</span> </div> <scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </scrip ...

Customizing textfield error color in MUI5 React based on conditions

I am looking for a way to dynamically change the color of error messages in my application, with warnings displaying in orange and errors in red. I prefer not to use useStyle as it is now deprecated in mui5. Below is the code snippet I have created: import ...

What is the process for linking to a backend on a distinct port in Next.js?

I am working on a project with Next.js and I am facing a challenge in connecting to a backend server that is running on a different port. The frontend of my application is on port 3000, while the backend is on port 8000. My goal is to interact with the bac ...

Webpack 5 is unable to load animated gif files

Hello, I am currently diving into webpack and following the official documentation at https://webpack.js.org/guides/asset-management/#setup. My goal is to incorporate an animated gif using webpack 5. Although the placeholder for the gif is loading, I enco ...