Copy and paste the following script.
<script
language="ecmascript"
type="text/ecmascript">
var web = null;
var listCollection =
null;
var list =
null;
var viewCollection =
null;
function getViews() {
var clientContext =
new SP.ClientContext.get_current();
if (clientContext != undefined
&& clientContext != null) {
this.web =
clientContext.get_web();
this.listCollection =
web.get_lists();
this.list =
listCollection.getByTitle("List Request");
this.viewCollection = list.get_views();
clientContext.load(this.viewCollection);
clientContext.executeQueryAsync(Function.createDelegate(this,
this.onQuerySucceeded),
Function.createDelegate(this,
this.onQueryFailed));
}
}
function onQuerySucceeded() {
var viewName =
'Views: \n';
var viewsEnumerator =
this.viewCollection.getEnumerator();
while (viewsEnumerator.moveNext())
{
var view =
viewsEnumerator.get_current();
viewName += view.get_title() +
'\n';
}
alert(viewName);
}
function onQueryFailed(sender, args) {
alert('Request failed. ' +
args.get_message() + '\n' +
args.get_stackTrace());
}</script>
<input
id="btnGetViews"
onclick="getViews()"
type="button"
value="Get All
Views" />