简体   繁体   English

解析-未捕获的TypeError:无法读取未定义的属性“ get”

[英]Parse - Uncaught TypeError: Cannot read property 'get' of undefined

I am using Parse with javascript. 我正在使用JavaScript解析。 I am trying to get an object and I am following the documentation closely. 我正在尝试获取对象,并且正在密切关注文档。 I still end up with the error 我仍然会遇到错误

Uncaught TypeError: Cannot read property 'get' of undefined 未捕获的TypeError:无法读取未定义的属性“ get”

$(document).ready(function(){

Parse.initialize("myInfo","myInfo");

var count = Parse.Object.extend('overallCount');
var myQuery = Parse.Query(count);

myQuery.get('Gqwk38uUYz', {  //HERE IS THE PROBLEM
    success: function(count) {
        // The object was retrieved successfully.
        var myCount = count.get('count');
        var updatedCount = myCount+1;

        $("#myNum").val(updatedCount);

        count.save(null, {
            success: function(count) {
                count.set('count', updatedCount);

                count.save();
            },
            error: function(model, error) {
                // This will be called.
                // error is an instance of Parse.Error with details about the error.
                if (error.code === Parse.Error.OBJECT_NOT_FOUND) {
                    alert("Uh oh, we couldn't find the object!");
                } else if (error.code === Parse.Error.CONNECTION_FAILED) {
                    alert("Uh oh, we couldn't even connect to the Parse Cloud!");
                }
            }
        });
    },
    error: function(object, error) {
        // The object was not retrieved successfully.
        // error is a Parse.Error with an error code and message.

    }
});
});

You are getting the error because myQuery is indeed undefined. 您收到错误消息是因为myQuery确实未定义。 You have to use "new" to create a query object. 您必须使用“新建”来创建查询对象。 It's also good practice to capitalize class names: 最好使用大写的类名:

var Count = Parse.Object.extend('overallCount');
var myQuery = new Parse.Query(Count);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 解析未捕获的TypeError:无法读取未定义的属性“ get” - Parse Uncaught TypeError: Cannot read property 'get' of undefined 未捕获的类型错误:无法读取未定义的属性“get” - Uncaught TypeError: Cannot read property 'get' of undefined Uncaught TypeError:需要库时无法读取未定义的属性“ parse” - Uncaught TypeError: Cannot read property 'parse' of undefined when requiring a library 未捕获的TypeError:无法读取未定义的属性“未定义” - Uncaught TypeError: Cannot read property 'undefined' of undefined 未捕获的类型错误:无法读取 VueJs 中未定义的属性“get” - Uncaught TypeError: Cannot read property 'get' of undefined in VueJs 未捕获的类型错误:无法读取未定义错误的属性“get” - Uncaught TypeError: Cannot read property 'get' of undefined error 捕获TypeError:尽管有条件,但无法读取未定义的属性“ get” - Getting Uncaught TypeError: Cannot read property 'get' of undefined in spite of the conditionals 为什么我得到 Uncaught TypeError: Cannot read property 'sequence' of undefined - why I get Uncaught TypeError: Cannot read property 'sequence' of undefined 未捕获的TypeError:无法读取未定义的属性“数量” - Uncaught TypeError: Cannot read property 'quantity' of undefined 未捕获的TypeError:无法读取未定义的属性'fromJSON' - Uncaught TypeError: Cannot read property 'fromJSON' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM