I have a list which i want to fetch at the front end using javascript based on some user inputs.

The list has 3 columns - 'Name', 'Branch' and 'Age', and the list is named 'Students'.

Now if the user wants to know the students under a particular branch then i have to fetch them dynamically and show it to the end user.

Please suggest me what should be done.

2 Answers 2


You can use below code snippet to achieve your functionality, here i have used ECMA script to access sharepoint list data. here is the msdn link for the same.

ExecuteOrDelayUntilScriptLoaded(GetStudentsData, "sp.js");

function GetStudentsData() {
  context = new SP.ClientContext.get_current();
  lstStudents = context.get_web().get_lists().getByTitle('Students');
  web = context.get_web();
  currentUser = web.get_currentUser();
  context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod),
                          Function.createDelegate(this, this.onFailureMethod)); 
function onSuccessMethod(sender, args) {
   var camlStudentsQuery = new SP.CamlQuery();

   // Pass your input parameters from page and you can pass those parameters through query
   camlStudentsQuery.set_viewXml('<View><Query><Where><IsNotNull><FieldRef Name="Branch"
   this.StudentsListItems = lstStudents.getItems(camlStudentsQuery);
   context.executeQueryAsync(Function.createDelegate(this, this.showStudentData),
function showStudentData()
// do your job here.
function onFailureMethod()
   // catch error here

You have two options

Options 1 : If you are using SP 2013 you can use OData which is very good with jQuery. Documentation for it is http://msdn.microsoft.com/en-us/library/office/fp142385.aspx

Options 2 : Otherwise you use codeplex project http://spservices.codeplex.com/

Both of above can work with jQuery and also help you to CRUD functions very gracefully

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.