Is it true that IE does not support passing callback parameters to setTimeout()?

When I used the js setTimeout function in my code, it worked perfectly in Firefox by reloading within seconds. However, the same code did not work in IE. I tried changing the method to 'POST', but received an error stating that the request was not supported. So, I changed it back to 'GET'. Any suggestions on how to make it work in all browsers?

function getCallDetails(cId){
    $.ajax( {
        url : 'callInfo.html?cId='+cId,
        method : "GET",
         dataType: "json",     
        success : function(data) {
        callResult=data.rows;

        showCallDetails(callResult,cId);
        },
        failure : function(form, action) {
        }
    });
    window.setTimeout(getCallDetails, 1000,[cId]);

}

Answer №1

Your current use of setTimeout is not compatible with Internet Explorer as it does not allow passing parameters to the callback function.

Furthermore, invoking setTimeout in this manner is highly incorrect; it will lead to a significant increase in concurrent requests due to each call resulting in two additional calls being generated.

Answer №2

Consider this alternative approach:

window.setTimeout(function() { fetchCallDetails(companyId); }, 1000);

Furthermore, I suggest relocating that statement within the success callback function.

Answer №3

Give this a shot:

window.setTimeout(function() {
    fetchCallInfo(callId);
}, 1000);

Let me know if that works for you!

Answer №4

One of the reasons for this issue is a cache problem that occurs in Internet Explorer.

This issue can be resolved by implementing the following code:

 function getCallDetails(cId){
        $.ajax( {
            url : 'callInfo.html?cId='+cId+'&randomNo='+ Math.rand(),
            method : "GET",
             dataType: "json",     
            success : function(data) {
            callResult=data.rows;

            showCallDetails(callResult,cId);
            },
            failure : function(form, action) {
            }
        });
        window.setTimeout(function() { getCallDetails(cId); }, 1000);


    }

Ensure that the random number is ignored on the server side.

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

Strategies for streamlining repetitive code within a closure in Angularjs

We are currently utilizing Angularjs 1x and I am in the process of refactoring some repetitive code within an Angularjs filter. However, I am facing challenges in getting it to function correctly. It should be a straightforward task. Our standard approach ...

Leverage the selected values to dynamically generate a table using jQuery

Can someone help me figure out how to store multiple values from a selection and then create an array using jQuery? Here's the scenario: In my multiple selection, I have 5 values: <select name="animal" id="animal" multiple="multiple">    ...

Mastering the art of crafting and managing NodeJS promises with finesse

Currently, I am utilizing ExpressJS for handling APIs and heavily rely on promises for managing asynchronous requests such as external API calls and database queries. While this approach works well in most cases, it tends to clutter the code with numerous ...

The element is not defined in the Document Object Model

There are two global properties defined as: htmlContentElement htmlContentContainer These are set in the ngAfterViewInit() method: ngAfterViewInit() { this.htmlContentElement = document.getElementById("messageContent"); this.htmlContentCont ...

What could be causing the error "no controller found" when attempting to call a web API post method?

I recently created a basic ASP.NET project that includes a WebAPI. However, I encountered an issue when trying to send a POST request from an HTML page to the WebAPI. Instead of success, I received an error message. The controller named 'api' do ...

I have a JavaScript code that smoothly scrolls to different id's on a webpage, but I need assistance in adding an exception for a particular id

I'm looking to incorporate smooth scrolling for all hash links in my JavaScript. However, I need the id=nav and its resulting hash link, /#nav, to be exempt from this functionality as it interferes with the menu responsiveness. Can someone provide gui ...

Merge arrays values with Object.assign function

I have a function that returns an object where the keys are strings and the values are arrays of strings: {"myType1": ["123"]} What I want to do is merge all the results it's returning. For example, if I have: {"myType1": ["123"]} {"myType2": ["45 ...

Tips for building a dynamic panel with an AjaxLink in Wicket?

I have been attempting to create multiple links that will update a table within a website using an AjaxLink from Wicket. Despite setting "setOutputMarkupId(true)" and using methods like "setDefaultModelObject" and "addComponent", the table remains unchange ...

Creating a Cancel Button in JSP/HTML/JS/CSS Form: A Step-by-Step Guide

It is necessary to incorporate the functionality of "save" and "cancel" in the JSP code for this particular form. By selecting "save", the data entered into the form will be submitted to its intended destination. Alternatively, choosing "cancel" will dismi ...

Error: Attempting to access an undefined property

I have a quite extensive Vue/Vuitify project that is not functioning correctly. I have simplified the project down to a small program to highlight the issue. Despite trying everything that comes to mind, and even some things that don't, I am unable to ...

Transform the appearance of several elements using querySelectorAll

When targeting class names in an HTML page with a checkbox using querySelectorAll, keep in mind that getElementByID only works with the first element. QuerySelectorAll displays a nodeList which might require some corrections - how can this be achieved? le ...

Using a timer to make Ajax calls twice on a single webpage

Can multiple ajax calls be made simultaneously on the same page to different receiving div tags? I am struggling to find a solution to this issue. I have a total of 3 pages: a home page, and two PHP pages named status and alert which echo the results. Wi ...

Leverage the power of AJAX to fetch and display controller action results on the current

this is my code of the view I've set up a dropdown menu with options that have values like /ControllerName/ActionName. Upon clicking one of the dropdown values, it redirects me to another page with the selected ControllerName and ActionName. However ...

Send form information using the REST method

Can someone provide guidance on how to properly handle this endpoint in my code? @PostMapping("/createUser") public ResponseEntity<User> createUser(@RequestBody User user) {...} I am looking to implement a user creation feature on my HTML ...

How to implement datepicker on multiple input fields

Below are the two input fields that have datepicker functionality: <div class="row"> <input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="dt" is-open="opened" min="minDate" max="'2015-06-22&apos ...

Tips for setting up Highcharts tooltip.headerFormat using the function getDate() plus 5

I'm facing a little challenge trying to understand how the JavaScript function getDate interacts with Highcharts datetime on xAxis. My goal is to show two dates in the tooltip header, forming a date range like this: 1960/1/1 - 1965/1/1. The first da ...

Angular 4 after ejection, coupled with automated end-to-end testing using Protractor/Selenium setup

I am attempting to conduct end-to-end tests using Protractor/Selenium on an Angular 4 project that has been ejected. Here is my package.json: ... "scripts": { "pree2e": "webdriver-manager update --standalone false --gecko false --quiet node", "e2 ...

What is the best way to set one property to be the same as another in Angular?

In my project, I have defined a class called MyClass which I later utilize in an Angular component. export class MyClass { prop: string; constructor(val){ this.prop = val; } public getLength(str: string): number { return str.length; } ...

css failing to load properly following javascript redirection

Upon clicking the button labeled id=cancel, the user will be directed to index.php. $('#cancel').click(function() { if(changes > 0){ $('#dialog-confirm').dialog('open'); }else{ window.location.href = ". ...

Leveraging the combination of <Form>, jQuery, Sequelize, and SQL for authentication and navigation tasks

My objective is to extract the values from the IDs #username-l and #pwd-l in an HTML form upon the user clicking the submit button. I aim to compare these values with those stored in a SQL database, and if they match exactly, redirect the user to a specifi ...