The objective of this post is to get choices from a list. It can be very helpful when you will create a custom form for adding or editing items.
$.ajax({
url: "host url"+"_api/web/lists/GetByTitle('List Name')/fields?$filter=EntityPropertyName eq 'Choice Field Name'",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function (data) {
console.log(data.d.results[0].Choices.results);
},
error: function (error) {
alert(JSON.stringify(error));
}
});
Above code is a typical ajax call using jQuery. Everything must be familiar to you. But something may be unknown to you like url. I have an article about REST in codeproject.
<a href="http://www.codeproject.com" rel="tag" style="display:none">CodeProject</a>