# Cannot read property 'jqXHR' of undefined

**URL:** <https://meta.discourse.org/t/cannot-read-property-jqxhr-of-undefined/58429>\
**Category:** Product Support\
**Created:** [March 5, 2017, 8:45pm UTC](https://meta.discourse.org/t/cannot-read-property-jqxhr-of-undefined/58429 "2017-03-05T20:45:49Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Stefan\_Brighiu\_M](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stefan_brighiu_m/32/174499_2.png) [@Stefan\_Brighiu\_M](https://meta.discourse.org/u/Stefan_Brighiu_M)\
**Post date:** [May 22, 2020, 6:56am UTC](https://meta.discourse.org/t/cannot-read-property-jqxhr-of-undefined/58429/11 "2020-05-22T06:56:18Z")

</div>

This error showed for me when I was doing the following.  
All done in a plugin.

I was adding a Validator to the Post class… the content of it does not matter but i will put it for the sake of the reply.

> # frozen\_string\_literal: true
> 
> class MainPostValidator \< ActiveModel::Validator  
> def validate(record)  
> puts ‘TTTTT’  
> p record
> 
> ```
> raw = record.raw
> 
> unless raw.present?
> post.errors.add :base, 'This record is invalid'
> end
> 
> ```
> 
> end
> 
> private  
> def some\_complex\_logic  
> # …  
> end  
> end

Before running the server with the new changes, I had the website opened on editing a post, ready to check if the save changes triggers my validator.

I restarted the server but did not refresh the page! When I tapped save changes on the post. I saw that error. It disappeared once i refreshed the page, and maybe restarted the server instance also.

This was all done in local dev.

Hope it helps 🙂

The validator was declared in a new file, and also the Post extra code to apply the validator was in a new file as well.

> `require_dependency 'post' Post.class_eval { include ActiveModel::Validations validates_with MainPostValidator }`

---

_[View the full topic](https://meta.discourse.org/t/cannot-read-property-jqxhr-of-undefined/58429)._
