Exploring ways to loop through a hash map following an ajax request, which contains 3 lists within its structure

Here is my code implementing a hashmap and an AJAX call:

Map<String, List<?>> map=new HashMap<>();

List<?> minimumParameters=new ArrayList<>();

map.put("min", minimumParameters);
map.put("max", maximumParameters);

// Performing an AJAX call to retrieve response data
$.ajax({
    url:'./getMinMaxAvgDataByMtrNo/'+meterNum+'/'+frmDate+'/'+tDate,
    type:'GET',
    success:function(response){
        if(response.length == 0 || response.length == null ){
            bootbox.alert("No data for this meter number "+meterNum);
        }
        else{
            alert(response);
        }
    }
});

Next step is how to iterate through the response in order to extract those lists.

Answer №1

If you receive a map in your response, here is how you can iterate over it using jQuery:

$.ajax({
    url:'./getMinMaxAvgDataByMtrNo/'+meterNum+'/'+frmDate+'/'+tDate,
    type:'GET',
    success:function(response){
        if(response.length == 0 || response.length == null ){
            bootbox.alert("No data for this meter number "+meterNum);
        }
        else{
            alert(response);
            $.each(response , function( key, value ) {
               console.log( key + "=" + value ); // min=List<> , can iterate over list if you need to .
          });
        }
    }
});

I hope this helps with what you are trying to achieve.

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

Comparing the efficiency of using arrays versus mapping to an object and accessing data in JavaScript

When considering the basics of computer science, it is understood that searching an unsorted list typically occurs in O(n) time, while direct access to an element in an array happens in O(1) time for HashMaps. So, which approach yields better performance: ...

Assign a value to ng-model using JavaScript

Encountering an issue while working with JavaScript in AngularJS. There is a text field identified by id="longitude". <input type="text" data-ng-model="newwarehouse.longtitude" id="longitude"/> The value of this field is being set using JavaScript. ...

Trouble with transferring URL parameter

I want to showcase my Controller code below: .when('/showprofile/:UserID', { templateUrl: 'resources/views/layout/showprofdile.php', controller: 'renameShowCtrl', }) Here is an example URL: Upon clicking the link, i ...

I'm encountering an issue: Uncaught ReferenceError

I am currently working on a to-do list project in javascript, but I keep encountering an error message that says: Uncaught ReferenceError: itemsjson is not defined. After setting my get.item to null, I proceeded to add .push to the code. Can someone pleas ...

What are the implications of using CSS classes for JavaScript markup?

The circumstances: An PHP-generated homepage using a template engine is currently undergoing a redesign. The new design is centered around jQuery UI elements. The current CMS utilizes various templates such as page, article details, and comments. The i ...

Is there a way to duplicate and insert a function in node.js if I only have its name?

I'm currently working on a code generation project and I've encountered a problem that I initially thought would be easy to solve. However, it seems to be more complicated than I anticipated. My task involves taking a method name as input, naviga ...

How can I incorporate a personalized checkbox into a column within a React material table?

I'm currently working on a React project where I am using a Material Table. I am trying to figure out how to add a checkbox in a table cell, for example, in the Birth year column instead of just having the year displayed. Can anyone provide guidance o ...

Unable to retrieve document location when using the first child <a> tag in IE6 and IE7

Here is the HTML code I am working with: <ul id="mainlynav"> <li><a href="#">text1</a> <ul class="subnavul"> <li> <a href="a.php">Link to a</a> </li> <li> ...

Java-based Selenium WebDriver Testing

Is there a way to confirm that when a user clicks on a book title in the bottom panel, they will be redirected to the Amazon site and see the same book with the matching title displayed? To do so, you can use the following code snippet: Driver.findElement ...

Select a component inside the <section> element

The element is embedded within a tag, but despite several attempts, I have been unable to successfully click on it. wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@value='Login to Register']"))).click(); Additionally, Web ...

Selecting a button with parameters in Selenium WebDriver: A guide for users

Here is my Java code snippet: package com.ej.zob.modules; import java.awt.List; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import org.junit.Assert; import org.openqa.selenium.By; import org.openqa.selenium.WebE ...

Using Ajax to request the Area Controller

I'm struggling to make a Controller call using Ajax, and I keep encountering the following error: Failed to load resource: the server responded with a status of 404 () The Ajax request is being made from the Admin View to the Admin Controller. Whil ...

Is there a way to make my code on Google Sheets work across multiple tabs?

My Google Sheets code successfully pulls information from the main tab into my CRM Software every time someone fills out a form online. However, I'm struggling to get the script to run for multiple tabs on the same spreadsheet. I've tried a few s ...

Arranging Initial Elements of String Arrays in an ArrayList

public ArrayList<Integer[]> customerArray= new ArrayList<Integer[]>(); The first elements are currently in String type, but I want to convert them into Integer and then sort them. 35 Murat Kaya 236-3446789 Address: Dikmen 4. Cadde 34/2 45 Hat ...

Display the name provided in a registration form on the confirmation page as a token of appreciation

I'm attempting to display the user's entered name in a Mailchimp form (where the name value is FNAME) on a custom thank you page (e.g. "Thank you NAME HERE,"). I haven't found a way to do this using Mailchimp's documentation other than ...

Incorrect color change on button triggered by onMouse actions and state fluctuations

While creating a user profile on my app, I encountered an issue with button coloring. When I try to add color functionality to the button, it turns red instead of green and remains red even when the mouse is not hovering over it. My goal is to have the but ...

Is forwardRef not explicitly exported by React?

UPDATE: The issue with the code implementation below has been resolved. It was discovered that the error was caused by a react-redux upgrade, as redux now requires functional components instead of class components. import React, { forwardRef } from ' ...

Error message on Android Web Console: ReferenceError - Worker object is not defined

As someone who is new to javascript, I have been struggling to understand why popular browsers seem to handle the definition "new Worker("BarcodeWorker.js")" differently than Android WebView. The original code for this Barcode Reader is from Eddie Larsso ...

Detecting Specific Web Browsers on My Website: What's the Best Approach?

My website is experiencing compatibility issues with certain browsers, such as Firefox. I want to display a message when users visit the webpage using an unsupported browser, similar to how http://species-in-pieces.com shows a notification saying "Works ...

Which specific jQuery event type is triggered when Ajax dynamically populates data into an input field?

In my form, there is a field for the user to enter an ID number. Using Ajax, I am able to check the database for this ID and then automatically populate other input fields with the corresponding person's information from the database. Once the data h ...