Utilizing IE's AJAX parsing capabilities in combination with the functions .includes() and .indexOf

What is the solution to make this code work in IE?

var tEvents = eventsJSON.response.Events.filter(function (val, index, array) {
         return val.participating_region.indexOf(varRegion) !== -1;
});
totalEvents = tEvents.length;

I am aware of the issue with .includes(), but I am unsure how to use .indexOf() instead.

Complete code:

var varRegion = $('body').data('region'); 

  var eventsJSON = null;
  var totalEvents;
  var virtualEvents;

  $.ajax({
    'url': '/services/getAllEvents',
    'dataType': 'json',
    'success': function (data) {
     eventsJSON = data;
     parseJSONevents();
    }
  });

  function parseJSONevents() {

    var tEvents = eventsJSON.response.Events.filter(function (val, index, array) {
     return val.participating_region.indexOf(varRegion) !== -1;
    });
    totalEvents = tEvents.length;

    $('.in-person-events').text(totalEvents);

    return eventsJSON;

  };

Answer №1

check if the participating region value includes the variableRegion

It can be challenging to provide a definitive answer without reviewing your complete code and JSON response setup.

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

Words program with the header feature incorporated

Hello, I am currently working with Laravel to build an HTML page and have successfully converted it to MS Word. However, I am now trying to add a header inside. Can anyone help me achieve this? Here is a snippet of my code: <body> <a class= ...

Success in handling data arrays for jQuery AJAX operations

After performing some operations on the server, I am returning an array. Once the Ajax call is successful, I want to manipulate this array. var addPaymentType = function(){ var data = new Object() data["function"] = "add"; data["payment ...

Tips for executing a script while updating npm version

Can a script be executed during the npm version command, after the release number has been incremented but before the git tag is created and pushed? ...

javascript implementing number formatting during keyup event

When I try to format a number in an input field on the keyup event, I receive a warning in my browser console that says "The specified value "5,545" cannot be parsed, or is out of range." The value in the input field also gets cleared. How can I solve this ...

Vue 2 checkbox form array data

Creating a checkbox list with a dynamic id and name: Data: yards[{id:1,name:'test'}] etc HTML: <ul class="checkbox-list"> <template v-for="(yard, index) in yards"> <li> ...

Simply tap on any part of the row to select the checkbox and bring attention to it?

Is there a way to make rows in a table selectable by clicking anywhere on the row? I have a script that displays checkboxes next to each result from a MySQL database, but I want users to be able to click anywhere on the row to select it and highlight the e ...

What is the best way to arrange a 2D array or multiple arrays based on the length of each array?

Can you create a Python function called def compare_lengths(x,y,z)? The function should take three arrays as arguments and determine their lengths, returning them as a triple in order of length. For example, if the input arrays are [1,2,3], [10,20,30,40] ...

PHP is mistakenly displayed on the incorrect webpage

Lately, I've been immersed in a website project. I have a website.php file that contains all the HTML code, a function.php file, and a saveArray.js file. Within website.php, I've included a HTML table with a button at the bottom. When this button ...

Steps to resolve the issue: ERROR Avoid nesting VirtualizedLists inside regular ScrollViews. This error can occur even if you are not using ScrollViews

I'm currently working on a react-native app and I need to create a layout with components arranged vertically, including a transaction history section. However, I'm encountering an issue when trying to display the transaction history data from du ...

Is there a way to automatically determine the text direction based on the language in the input text?

When posting in Google Plus (and other platforms), I noticed that when I type in Persian, which is a right-to-left language, the text direction changes automatically to rtl and text-alignment:right. However, when I switch to English, the direction switches ...

Adding a CSS class dynamically to a table cell in the backend using Vb.net

Currently, the layout of my table looks like this: <tr> <td> Field1 </td> <td> Field2 </td> <td> Field3 </td> <td> Field4 </td> <td> Field5 </td> </tr> <tr> & ...

Ext 4.1 - Accessing a class instance using Ext.define()

In my code, I have a class with a method defined like this: Ext.define('MY.class.Manager', { .... .... .... manageStuff: function(){ } } Initially, the manageStuff function was only needed in one place and everything worke ...

Transforming a C# .NET list of strings into an HTML dropdown menu

I've created a list of strings in my c# .net application and I want to store this list in an HTML dropdown. However, I'm not sure if I've done everything correctly in my view. Here's the code snippet: CalendarFolder calendar = ...

How can I set the position of a JavaScript popup to load automatically? It currently only works when the window

I designed a basic popup in jQuery, and everything appears to be functioning smoothly except for the on-load event in the infoPopupLoadResize() function. It's puzzling why it doesn't trigger when the page loads but works correctly during resizing ...

Error message received when using HttpPost in asp.net

Every time I try to make an HttpPost request using ASP.NET Web API, I keep getting an error from the AJAX call. This is my controller: public class ContactController : ApiController { [HttpPost] [EnableCors(origins: "http://localhost:52884", he ...

Ensure that numpy constructs an array containing objects

Let's start with an array: arr = np.array([[1, 2, 3], [4, 5, 6]]) Now, we want to create another array with shape=(1, 1) and dtype=np.object where the only element is our initial array. We attempted this code: a = np.array([[arr]], dtype=np.object ...

Searching for the perfect jQuery regex to validate date formats

In my application, there is an input box that allows users to enter a string date like "today" or "tomorrow". However, I am facing a new challenge now - dates such as "3 march" or "8 january." The input box includes a dropdown menu feature where users can ...

Leveraging Mermaid for angular applications

As a newcomer to Mermaid, I am attempting to integrate it into my Angular project. Placing it in my HTML has proven successful. <script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.0.1/mermaid.min.js"></script> <div class="merma ...

Transforming data from a JSON format into a JavaScript array

I'm trying to convert a JSON string into an array containing the values from the JSON. When I use json.stringify(jsonmybe) and alert it, I see [{"role":"noi_user"},{"role":"bert_user"}] (which is in JSON format). My goal is to extract `noi_user` and ` ...

Issues arise with req.body being undefined when using node.js in conjunction with Express version 4.16.X and Body-Parser version

Recently, I began using node.js to construct a RESTFul API. Currently, my focus lies in inserting data through POST requests with JSON in the body. However, I encountered an issue where the req.body always returned as undefined. Upon investigating further ...