I am looking to send a Dictionary> from the server to the client using JavaScript.
Although I came across this post, I am still unsure about the steps to follow. To clarify my objective, the dictionary comprises the 'name' key of all worksheets in an Excel file, with the 'value' representing the column value of the first row in each worksheet. The user interface on the client side should include two drop-down lists: one containing the names of all worksheets in the Excel file (keys), and the other displaying the column values of the first row of the selected worksheets (values).
The C# backend code is functioning correctly. Right now, I require assistance with the frontend JavaScript implementation.
How can I structure the data as key-value pairs in order to perform a "search" based on the keys chosen by the client? Once a key is selected from the first drop-down list, I need to retrieve the corresponding values in a list format.
Thank you!
var ajaxRequest = $.ajax({
type: "POST",
url: "http://localhost:1894/api/Values",
contentType: false,
processData: false,
data: data,
success: function(dataTest) {
}
});
Here is the JSON response received from the server:
{"First":["Name","Link","User","Pass"],"Sec":["test01"]}
In JavaScript, how can I search through this data similar to C#? I aim to achieve something like "dict.TryGetValue(key, out value);" where the value returned is an array of strings or a List.