You're assigning data to $data here, but not making it a jQuery object. Also, data isn't used in this function at all.