That is the JQuery:
$(function () {
$('#dish-filter-form').on("submit", function (e) {
e.preventDefault();
var dishName = encodeURIComponent($('#dishName').val());
var selectFoodType = encodeURIComponent($('#selectFoodType').val());
var cities = ["New-York", "Tokyo", "Madrid"];
var strCities= JSON.stringify(cities);
console.log(strCities);
$('.toLoad').load('/Dishes/Search?dishName=' + dishName + "&cities[]=" + strCities+ + "&selectFoodType=" + selectFoodType);
});
});
This is the signature of my Search method in DishesController:
public async Task<IActionResult> Search(string dishName, string[] cities, string selectFoodType)
When debugging I see that dishName and selectFoodType have been read well but cities is always an empty array, although that my console shows me that the array: strCities
is as I wish.