Creating a Simple FAQ page fetching from Sharepoint 2013 List

There was a question asked in stackoverflow regarding “Dynamically Showing/Hiding Panels using JQuery”

Here the author had a scenario where he wanted to create a FAQ page fetching data from a Sharepoint List and toggle Response visibility by clicking on Question.

So here is the code for that (thanks to the author of question as I’ve just modified the code slightly to fix the issue he had)

In this scenario we have a custom list FAQs with two Columns “Question” and “Response”

[sourcecode language=”javascript”]
<script src="/sites/AppDemoSite/SiteAssets/jquery-1.9.1.js">
</script><script type="text/javascript">

var soapEnv =
"<soapenv:Envelope xmlns:soapenv=’’>
<GetListItems xmlns=’’>
<FieldRef Name=’Question’ />
<FieldRef Name=’Response’/>
<fieldRef Name=’ID’/>

url: "/sites/AppDemoSite/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset="utf-8""
function processResult(xData, status) {
$(xData.responseText).find("z\:row").each(function() {
var iDesc=$(this).attr("ows_Question");
var iResp=$(this).attr("ows_Response");
var iID=$(this).attr("ows_ID");
var liHtml = "<div class=’question’ id=’"+iID+"’>" + iDesc + "</div><div class=’answer’ id=’a"+iID+"’><a href=’/sites/AppDemoSite/Lists/FAQs/DispForm.aspx?ID=’"+iID+"’>"+ iResp +"</a></div>";
<h1>A Big Fat FAQ</h1>
<div id="FAQ">

Leave a Reply

Your email address will not be published. Required fields are marked *