I’ve been running into this .data() function from jQuery recently, thinking it had something to do with AJAX. Here’s the deal.
.data() is just a cross-browser way to simulate the usefulness of the data-attributes feature of html, which was just a hook on all html elements that allows us to attach whatever data we find helpful. I’ve used these a lot.
So the jQuery .data() function can be used to pull data from the data-attributes of your html elements, but it doesn’t actually write anything to there. It only simulates this behavior (probably more robust that way) to create persistent data storage.
Also helpful: .removeData()
Learn more here.