The webpage becomes unresponsive and crashes within a matter of minutes

When my website is hosted on a server, it becomes unresponsive, freezes, and crashes after a few minutes. However, everything works fine when I run it locally on localhost while pulling API data from a Flask Server app.

The Flask-based API engine retrieves JSON data every second, updating the Google Map marker based on the latitude and longitude received from the API.

My expectation is that the webpage should not freeze or become unresponsive.

var map_lat = 28.644800;
var map_lon = 77.216721;
var head = 0;
var ngUrl = "http://*******.com/";

function httpGet(theUrl) {
  var xmlHttp = new XMLHttpRequest();
  xmlHttp.open("GET", theUrl, false); // synchronous request
  xmlHttp.send(null);
  return xmlHttp.responseText;
}

function buttonFunctionPR(id) {
  url = ngUrl.concat("x1/");
  var response = httpGet(url + id);
  response = JSON.parse(response);
  document.getElementById("message").innerHTML = response['msg'];
}

// Asynchronous functions for continuous data retrieval and display

hcFunOne = async() => {
  // Function content here...
}

hcFunTwo = async() => {
  // Function content here...
}

hcFunThree = async() => {
  // Function content here...
}

hcFunFour = async() => {
  // Function content here...
}

hcFunFive = async() => {
  // Function content here...
}

// Initiate asynchronous functions
setTimeout(function() {
  hcFunOne();
  hcFunTwo();
  hcFunThree();
  hcFunFour();
  hcFunFive();
}, 500);

// Google Maps functionality

var map;
var markers = [];

function initMap() {
  // Initialize map and markers
}

function addMarker(location) {
  // Add marker to the map
}

function setMapOnAll(map) {
  // Set map for all markers
}

initMap(); // Initializing the map

Answer №1

Your current rate of sending http requests per second is exceeding the recommended limit. It might be beneficial to switch to WebSocket for more efficient communication.

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

The function Yii2 isAjax returns a boolean value of false

Encountered an issue while attempting to run some code, even though it worked previously. Using AJAX to execute the code, but it resulted in a 500 error. Came across several posts with similar issues and their solutions, but none of them resolved the iss ...

What is the reason behind the Placeholder not functioning in IE8?

Whenever I trigger the onblur event on an input of type "password", it will hide both the placeholder text and the input itself. Check out the GitHub link for this plugin ...

React: State does not properly update following AJAX request

I'm currently facing a challenge in my React project where I need to make two AJAX calls and update the UI based on the data received. Below is the implementation of my render method: render() { if (this.state.examsLoaded) { return ( ...

What is the method for assigning a value to a JSON object using data from another JSON object?

I am faced with the task of setting the seqNo property in one JSON object, b, based on the id from another JSON object, a. How can I achieve this? var a = [{id: "Make", seqNo: 4}, {id: "Model", seqNo: 1}, {id: "XModel", seqNo: 2 ...

Encountered an issue with resolving the module specifier while attempting to import a module

Whenever I attempt to import a module, I consistently encounter this error message Failed to resolve module specifier "mongodb". Relative references must start with either "/", "./", or "../". and I have searched ext ...

Angular, ng-model, and input bugs causing problems

UPDATE: Jonathan's advice did the trick. I experimented with version 1.1.5, but it triggered a "Duplicates in a repeater are not allowed" error due to duplicate empty strings. I'll choose a solution after work; my current browser has limited func ...

In an AJAX response, the button will be disabled if any checkboxes are left unchecked, regardless of their group

This text has been inspired by a thread on Stack Overflow regarding disabling a button based on checkbox selection In the original post, the button is disabled unless at least one checkbox is checked. In my scenario, I have two sets of checkboxes: <d ...

React Native: Implementing scroll-based header animations in ScrollView

Currently, I am working on implementing an animated header with ScrollView on the screen. In this implementation, I need to set my view based on the Y position of the ScrollView during scrolling. This is how it's done: const onScroll = ({ nativeEvent: ...

Working with the Enter Key in Vue.js

I am faced with a challenge involving a text field and a button setup. By default, the button is set to submit a form when the Enter key is pressed on the keyboard. My goal is to capture each key press while someone is typing in the text field, particularl ...

Error: Module not found - Unable to locate 'dropzone'

Since migrating from Angular 4.4 to Angular 8.0, I encountered the following issue: ERROR in ./src/attributes/import/import.component.ts Module not found: Error: Can't resolve 'dropzone' in 'C:....\src\attributes\imp ...

Is it possible to update a URL in PHP without having to refresh the entire page by utilizing JavaScript?

Below is the JavaScript function I am using to create a URL: function reload(form){ var val1=form.dav.options[form.dav.options.selectedIndex].value; var val2=form.pathogen.options[form.pathogen.options.selectedIndex].value; var val3=form.topicF.options[for ...

Newbie inquiry regarding the setup and utilization of Bootstrap

I'm currently working on building a website and I decided to incorporate a bootstrap carousel. Initially, I had a dropdown button in the navbar along with a collapsible menu for smaller viewports which were functioning properly. However, when I added ...

The implementation of an onclick event in a freshly created HTML element is functioning solely on the final element

One issue I encountered was that when I generated page number buttons at the bottom of a page, the onclick event only worked with the last button created. Below is an example of how the page buttons were displayed: https://i.stack.imgur.com/wHwI0.png ...

"In Vim, learning how to create block comments is an essential skill to

I am seeking a way to streamline the process of generating block comments for documentation in vim. For example: /** * comment */ Are there any available plugins that can assist with this task? ...

Is there a way to modify the dimensions of this container? (CSS)

After performing a search and clicking on a result, a white bubble pops up on the map. I am looking to use CSS to make this bubble smaller as it is currently too large. Can anyone provide guidance on how to achieve this? ...

Organizing HTML elements based on their class names, especially when an element has multiple classes assigned

Hey there, I've been working on an artist page that showcases multiple artists, each with a portfolio image and some detailed information. My goal is to have buttons at the top of the page that, upon clicking, will sort the artists displayed. To achi ...

Issue with onDblClick event in Angular5 and PrimeNG's p-listbox

I encountered an issue while using p-listbox's onDblClick event as it does not return the selected list element. Instead, the event object only contains the value of 'this'. {"originalEvent":{"isTrusted":true}} HTML Blockquote <!-- S ...

Effective ways to transfer data between services and controllers

Is there a way to pass values from services to controllers effectively? Despite researching on stackoverflow, I haven't found a solution that addresses my issue. My goal is to access google spreadsheets using tabletop.js. Interestingly, when I log val ...

How to handle multiple file uploads and save information in dual tables using Laravel

Currently, I am dealing with a <form> that allows users to upload multiple files. However, my requirement is to store these uploaded files in a separate table within the database. Unfortunately, the files are not being saved into the database for som ...

What could be the reason for a jQuery script failing to execute when included in a PHP include statement from a different PHP page?

I'm currently working with javascript and php to manage cookies across different pages. On one page, I have a script that sets a value in a cookie variable and I want to retrieve that value on another page. Let's say the first page is named page1 ...