Я пытаюсь отправить массив javascript на мой веб-сервер для запроса ajax.Вот мой код:
function SearchTasksByTags() {
// Get the list of tags currently chosen
var tags = [];
$('.tagit-choice input').each(function () { tags.push($(this).val()); });
// If we have no tags, don't bother searching and just clear the current results
if (tags.length == 0) {
$('#tagSearchResults').empty();
return;
}
// Retrieve the search results from the server
$.ajax({ url: '<%= Url.Action("SearchByTags") %>',
data: tags,
type: 'POST',
success: function (html) {
$("#tagSearchResults").empty().append(html);
}
});
}
Массив формируется правильно, так как, когда я нажимаю на вызов $.ajax()
, инструменты разработчика Chrome показывают объект тегов как массив с 2 элементами (все элементы являются просто строками).).
Однако, согласно фиддлеру, фактические параметры записи, отправляемые на сервер:
undefined=undefined
Что я делаю не так?
Редактировать Console.Log показывает:
console.log(tags)
["portability", "testing"]
undefined