[Vuejs]-This.$emit is not a function within ajax success request

0👍

this property has access to your scope level properties because it’s a function and not an arrow function. So when you access the properties or method which is not in the scope of that function, it returns undefined or not a function.

To fix it, Make your success function as an arrow function of Javascript.

success: (result) => {
            this.$emit('update:pets', updated);
        },

Another way is to remove the self inside the success method and use the outer self.

success: function (result) {
            self.$emit('update:pets', updated);
        },

Leave a comment