简体   繁体   中英

var query not returning required results

I have a javascript file which is returning results to a HTML page via information entered in a SharePoint list. It works fine, but I've been asked to return another field of multiple text called 'Further Details'. However it's not showing up on the HTML page. I've checked the console and the information being entered in the Further Details field is being returned, it's just not showing on the HTML page. The rest (Current Status, Typical Usage etc) are showing fine.

The Do I need to add something to the var query URL? I've post the JavaScript and relevant HTML below:

 function getDeviceKnownIssues() { var txtfurtherinfo = ""; var txtTitleKnown = "<ol>"; var query = "**http://example.com/sites/it/ITInfrastructure/_vti_bin/listdata.svc//Knownissues?$filter=DeviceID eq " + window.DeviceId + ** ""; var call = $.ajax({ url: query, type: "GET", dataType: "json", headers: { Accept: "application/json;odata=verbose" } }); call.done(function(data, textStatus, jqXHR) { console.log(JSON.stringify(data)); $.each(data.d.results, function(index, item) { txtTitleKnown += "<li>" + item.Title + "</li>"; if (item.Info != undefined) { txtfurtherinfo += item.Info + "\\r\\n"; } }); txtTitleKnown = txtTitleKnown + "</ol>"; $('#knowntitle').append(txtTitleKnown); $('#furtherinfo').append(txtfurtherinfo); }); call.fail(function(jqXHR, textStatus, errorThrown) { alert("Error retrieving data: " + jqXHR.responseText); }); } 
 <tr> <td class="tg-yw4l" colspan="3"> <h2>Known Issues</h2> <div id="knowntitle"></div> <input type=button onClick="location.href=**'http://example.com/sites/it/ITInfrastructure/_layouts/listform.aspx?PageType=8&ListId={5968ECC4-3049-4794-B6DC-130763C01043}&RootFolder=**'" value='Submit a known issue'> </td> <td class="tg-yw4l" colspan="3"> <h2>Accessories</h2> <div id="deviceacc"></div> </td> </tr> <tr> <td class="tg-yw4l" colspan="3"> <h2>Typical Usage</h2> <div id="deviceuse"></div> </td> <td class="tg-yw4l" colspan="3"> <h2>Current Status</h2> <div id="imageContainer"></div> </td> </tr> <td class="tg-yw4l" colspan="3"> <h2>Further Information</h2> <div id="furtherinfo"></div> </table> 

It seems that you have basic html syntax error.

I would start from that.

You are not opening and closing your 'table row' <tr> and 'table data' <td> tags properly. Should be like this:

[...]
<tr>

    <td class="tg-yw4l" colspan="3">
      <h2>Further Information</h2>
      <div id="furtherinfo"></div>
    </td>

    <td class="tg-yw4l" colspan="3">
    </td>

</tr>
</table>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM