无法使用';在';操作员搜索';728';在里面


Cannot use 'in' operator to search for '728' in

我正在从php将其json编码回这个js文件,并且我得到了不能使用'in'运算符进行搜索。我打开window.aalert(数据),它看起来是正确的。

未捕获类型错误:无法使用'in'运算符在{"0":{"Name":"Duncan Davis"、"0":"Duncan戴维斯"、"Type":"Student"、"1":"Andrew Mackey"、"0:"Andrew Mackey"、"Type:"Professor"、"1:"Prospector"}、"2:"Name":"Joe Smith"、"0="Joe Smith"、"Type="Student"、"1":"Student"}、"3":{"Name":"John Hightower","0":"约翰·海托尔","Type":"Professor","1":"教授"},"4":{"Name":"Cat collectors","0":"Catcollectors"、"Type":"Group"、"1":"Group"}、"5":{","1":"Book"},"8":{"Name":"Dictionary Of POTATOES","0":"Dictionary Of POTATOES","Type":"Book","1":"Book"}}

$(function () {
$("#login_form").on('submit', function () {
    var Input = document.test.Input.value;
window.alert(Input);
    // use ajax to run the check
    $.ajax({
        url: '../php/DBConnect.php',
        type: 'POST',
        data: Input,
        success: DataReturn,
        error: function (xhr, status, err) { }
    });
    return false;
});
function DataReturn(Data) {
    window.alert(Data);
var tableheader = "<thead><tr><th>Name</th><th>Type</th></tr></thead>";
    $('#table').empty();
    $('#table').append(tableheader);
    $.each(Data, function (index, item) {
        $('#table').append('<tr><td>'
        + item['Name']
        + '</td><td>'
        + item['Type']
        + '</td></tr>');
    });
}

});

$.ajax({
    url: '../php/DBConnect.php',
    type: 'POST',
    data: Input,
    success: DataReturn,
    error: function (xhr, status, err) { }
});

添加dataType: 'json'

$.ajax({
    url: '../php/DBConnect.php',
    type: 'POST',
    data: Input,
    dataType: 'json',
    success: DataReturn,
    error: function (xhr, status, err) { }
});