I have used below code for getting list items from SharePoint list. Output is coming in alerts but it is not displayed in HTML controls.

<html lang="en-US">
    <meta charset="UTF-8">
<script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.7.1.js"></script>

    function insightViewModel() {
        var self = this;

        self.insights = ko.observableArray();
                url: "http://demo/Dev/_api/web/lists/getbytitle('CountryNames')/items",
                type: "GET",
                headers: {
                    "accept": "application/json;odata=verbose",
                error: function (error) {


            function suc(data)

                                for(var i=0;i<5;i++)


         ko.applyBindings(new insightViewModel());

    <tbody data-bind="foreach:insights">

            <td data-bind="text:CountryName"></td>

This is the output of data.d.results from sharepoint site. I have used this code in script editor.

enter image description here

1 Answer 1


Your code works fine, check this fiddle: http://jsfiddle.net/n869w8yh/

I replaced your request to SharePoint with a example array.

Just make sure you type the names of the fields correctly, don't forget case sensitivity. The for-loop is hard coded to 5 items in your code, do you have 5 items in that list?


Finally got some time to test this in a script editor. Try this in your code:

$(document).ready(function() {
  ko.applyBindings(new insightViewModel());
  • yes I have 5 items
    – KumarV
    Nov 4, 2015 at 10:04
  • 1
    Could you update the question with the result you're getting back from SharePoint? I would like to see what's in data.d.result. Nov 4, 2015 at 10:14
  • I see that you have updated the question with the result of data.d.results. I should have been more precise, how does one of those object look? Do they contain both the attributes CountryName AND Title? You can use JSON.stringify(data.d.results[0]) or alert(data.d.results[0].CountryName + " - " + data.d.results[0].Title); Nov 4, 2015 at 10:39
  • I have used this, " alert(data.d.results[0].CountryName + " - " + data.d.results[0].Title); " and it is giving me the results like " india - hello" from sharepoint list
    – KumarV
    Nov 4, 2015 at 10:48
  • @vikashkumar please see my updated answer. Nov 5, 2015 at 18:32

Your Answer

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

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