When getting field by title, it doesn't work. You should get it byInternalNameOrTitle. The reason is, it's SharePoint! This is why it is so hated and this is why it is so loved :)
This code piece worked for me (while if I replaced getByInternalNameOrTitle to getByTitle - I get the same error as you do):
var context=SP.ClientContext.get_current();
var field = context.get_web().get_availableFields().getByInternalNameOrTitle("Priority");
var fieldChoice = context.castTo(field, SP.FieldChoice);
context.load(fieldChoice);
context.executeQueryAsync(function() {
var choices = fieldChoice.get_choices();
console.log(choices);
},
function(s,a){
alert('ERR: ' + a.get_message());
});
Also, this question is sort of duplicate of this one:
- How to get a list of all Choice field options using Client Object ModelHow to get a list of all Choice field options using Client Object Model
So don't forget to upvote Ryan's answer ;)
Though I think it doesn't hurt to emphasize that getByTitle doesn't work in this case.