none
Visual Studio Sharepoint RRS feed

  • Question

  • i have this JQuery code to view list from sharePoint ,and my problem is the code cannot enter the while loop 

    can anyone help me 

    <script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
        <script type="text/javascript" src="/_layouts/15/sp.js"></script>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script>

    <table id="products" style="width: 100%;">
        
    </table>
     

        <script type="text/javascript">

            $(function () {
                alert("inside");
            GetProdecuts();
                $('#products').bootstrapTable({
                data: data
        });
    });
               var teamURL = 'https://m365x827238.sharepoint.com/sites/pwa/';
            function GetProdecuts() {
            var clientContext = new SP.ClientContext(teamURL);
        alert("four");
        var oList = clientContext.get_web().get_lists().getByTitle('Bussness');
        var caml = new SP.CamlQuery();

    alert("five");
        caml.set_viewXml("<View><Query> <Where> <Eq><FieldRef Name='Project_x0020_Id' /><Value Type='Text'>aae9a98f-0b79-e811-80d5-00155da42916 </Value></Eq></Where></Query></View>");
    alert("five");
    this.collListItem=oList.getItems(caml);
    clientContext.load(collListItem);
    alert("six");
    clientContext.executeQueryAsync(this.onQuerySucceeded, onQueryFailed());
    alert("seven");
    }
        function onQuerySucceeded(sender, args) {
                alert("ten");
            var listEnumerator =collListItem.getEnumerator();
            alert("listEnumerator");
                var ProductInfo = '<thead>' + '<tr>' + '<th>Title</th>' + '<th>phone</th>' + '</tr>' + '</thead>';
             alert("ProductInfo1");
       while(listEnumerator.moveNext())
    {     
       var Listone = listEnumerator.get_current();
      ProductInfo += '<tr>' + '<td>' + Listone.get_item("Title") + '</td>' +'<td>' + Listone.get_item("ProjectId") + '</td>' + '</tr>';
    }
                ProductInfo += '<tbody>';
    $('#products').html(ProductInfo);
          alert("insideloop1");
        }

    function onQueryFailed() { }
    </script>
    Sunday, July 1, 2018 9:32 AM

Answers