TypeError: invalid 'in' operand obj in jquery 1.9.1 version

后端 未结 7 2947
走了就别回头了
走了就别回头了 2021-02-20 16:25
$.ajax({
    async: false,
    type: \"POST\",
    url: url+\"module/listing/\"+projectId,
    data: \"ajax=true\",
    success: function(response) {
        $.each(resp         


        
7条回答
  •  长发绾君心
    2021-02-20 16:51

    I had the same problem. The error is being triggered from the jQuery function 'isArraylike( obj )' from the following line:

    return type === "array" || type !== "function" &&
        ( length === 0 ||
        typeof length === "number" && length > 0 && ( length - 1 ) in obj );
    

    The Javascript 'in' operator needs an object as operand, so chances are if you do jQuery.type(response) it'll show something other than an object (eg. string or null)

    So Amit's answer should work - if not, check the type of the response data and work from there.

提交回复
热议问题