为什么Jquery发送的是";未定义=未定义;作为我的post参数而不是发送数组数据?

为什么Jquery发送的是";未定义=未定义;作为我的post参数而不是发送数组数据?,jquery,ajax,arrays,Jquery,Ajax,Arrays,我正试图向我的web服务器发送一个javascript数组以请求ajax。这是我的密码: function SearchTasksByTags() { // Get the list of tags currently chosen var tags = []; $('.tagit-choice input').each(function () { tags.push($(this).val()); }); // If w

我正试图向我的web服务器发送一个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);
            } 
        });
    }
我做错了什么

编辑 控制台。日志显示:

console.log(tags)
["portability", "testing"]
undefined

console.log(标签)对标签有何评价

尝试按如下方式发送:

data : ({tags : tags})

标记
不是关联数组,因此我认为jQuery很难从中构建查询字符串。虽然我很惊讶它会将其视为未定义的,但这可能就是问题所在。将console.log输出添加到questionThis工作了!(尝试解决方案之前,我忘记刷新页面)
data : ({tags : tags})