If you're using CB Query Field for that then it's probably due to the below bug.
forge.joomlapolis.com/issues/6796
Workaround is to set "Allow Moderators to Edit User Profiles" within CB > Configuration > Moderation to at least "Super Administrators Only". If set to "No" the ajax calls will fail when editing users other than your self. Your code snippet is irrelevant to your issue and no idea where it's coming from.