2

Going round in circles. I'm trying to return results from two columns on a SharePoint list SharePoint Columns pictured, which will return the results to a HTML page HTML Result which is being created by a different JavaScript page which is querying a different SharePoint list.

This JavaScript isn't returning the results from the SharePoint list called KnownIssues. Don't know why!

I think it my be something to do with call.done line.

JavaScript and HTML below:

function getDeviceKnownIssues() {

  var txtTitleKnown = "";

     var query = "http://collaboration-dev.xxx/sites/it/SystemInventory/_vti_bin/listdata.svc/Knownissues?$select=IssueID,Title"; 



var call = $.ajax({
        url: query,
        type: "GET",
        dataType: "json",
        headers: {
            Accept: "application/json;odata=verbose"
        }       
    });
**call.done(function (data,textStatus, jqXHR){
$.each(data.d.results, function(index, item) {
        var KnownTitle = item.Title;**

          txtTitleKnown = "<p"> + KnownTitle + "</p>";

                });
   $('#knowntitle').append(txtTitleKnown);


});
call.fail(function (jqXHR,textStatus,errorThrown){
    alert("Error retrieving data: " + jqXHR.responseText);
});

}

HTML

<html xmlns:mso="urn:schemas-microsoft-com:office:office"  
 xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"><head>

<script src="/jquery-1.10.1.min.js"></script>

<script src="/it/SystemInventory/SiteAssets/scripts/moment.min.js"></script>
<script src="/sites/it/SystemInventory/SiteAssets/getDevices.js"></script>
<script 
src="/sites/it/SystemInventory/SiteAssets/getDeviceDetails.js"></script>

<script 
src="/sites/it/SystemInventory/SiteAssets/getDeviceKnownIssues.js"></script>

<script type="text/javascript">

function parseQueryString(queryString)
{
var params = {}, queries, temp, i, l;
queries = queryString.split("&");
for ( i = 0, l = queries.length; i < l; i++ ) {
    temp = queries[i].split('=');
    params[temp[0]] = temp[1];
}
return params;
}

$(document).ready(function(){
function getDeviceID() {
    if(typeof parseQueryString === "function") {
        if(window.location.href.indexOf("?") >= 0) {
            var qs = parseQueryString(window.location.href.split("?")[1])
            window.DeviceId = qs.did;
            getDeviceDetails();
            getDeviceKnownIssues();
        }
    }
}
getDeviceID();
getDevices();

 });


</script>
</head>
<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-    style:solid;border-width:1px;overflow:hidden;word-break:normal;}
.tg .tg-yw4l{vertical-align:top}
</style>
<table class="tg">
  <tr>
    <td class="tg-yw4l">
    <h1>Devices</h1>
    <div id="devices">
    </div>
</td>
<td class="tg-yw4l">
    <h1>Device Details</h1>
    <div id="devicedetails">
    </div>
</td>
<td class="tg-yw4l">
<h1>Device Overview</h1> 
    <div id="deviceoverview">
     <div id="devicekind">   
    </div>
  </td>
  </tr>


 </table>

<table class="tg">
  <tr>
   <td class="tg-yw4l">
    <h1>Accessories</h1>
    <div id="deviceacc">

    </div>
</td>
<td class="tg-yw4l">
    <h1>Typical Usage</h1>

    <div id="deviceuse">
    </div>
</td>
<td class="tg-yw4l">
<h1>Spare Cell</h1> 
    <div id=" ">



    </div>
</td>
  </tr>




</table>
Known Issues
<table class="tg">

Title


Service Status

    <div id="servivestatus">
    </div>
   </td>
    <td class="tg-yw4l">
   <h1>Device Type</h1> 
    <div id=" ">



    </div>
 </td>
  </tr>




</table>

<!--[if gte mso 9]><xml>
 <mso:CustomDocumentProperties>
<mso:_dlc_DocId msdt:dt="string">ITDOCUMENTS-135-47</mso:_dlc_DocId>
<mso:_dlc_DocIdItemGuid msdt:dt="string">1d6007ea-9e58-4298-b2d6-  
9196e2678ea3</mso:_dlc_DocIdItemGuid>

 <mso:_dlc_DocIdUrl msdt:dt="string">http://collaboration-
   dev.norgine.com/sites/it/SystemInventory/_layouts/DocIdRedir.aspx?
 ID=ITDOCUMENTS-135-47, ITDOCUMENTS-135-47</mso:_dlc_DocIdUrl>


 </mso:CustomDocumentProperties>
 </xml><![endif]-->
  • Have you tried sticking a break point on $.each(data.d.results, function(index, item) and seeing what is actually in data.d.results? – Bunzab Jun 2 '17 at 10:23
0

First suggestion is to stop using the (old) SOAP (_vti) API

And use the REST API

Its a minor change in the endpoint but saves you shitload of SOAP/XML headaches

https://dev.office.com/sharepoint/docs/sp-add-ins/complete-basic-operations-using-sharepoint-rest-endpoints

Second suggestion is not use the .html extension for your file... lot of headaches there because SharePoint (as a 'Publishing' CMS) rewrites those files and adds the metadata at the bottom, AND rewrites URIs in the content as well.

use the .aspx extension, that will execute the same as an .html file (but SP won't touch its contents)

third suggestion is to review what you are doing. To me it seems like you are creating One Page with the Contents from N Lists.

You are doing what SharePoint does

Why not a SharePoint WebPart page with multiple List Views?

Saves you all the coding, if you want Customizations you use the WYSYWIG Cisar Editor, which does all the JavaScript templating and JSLink management for you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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