When I run my code, it gives me an error "ReferenceError: MyVariable is not defined" on var comm_Id, I am trying to fetch the page ID and then generate the URL to call the rest API
this "${community.id}" fetches the ID of the page dynamically.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var comm_Id = ${community.id} //MyVariable being the supposed ID of the page
var cat_id = ${coreNode.ancestors[0].id}; //Category ID of the boards parent
var restUrl = "/"+comm_Id+"/restapi/vc/categories/id/"+cat_id;
$.ajax({
type: "GET",
url: restUrl,
contentType: "text/xml; charset=utf-8",
data: "DATA",
success: function (response) {
var index = 0;
var fltBoardID = "";
var boardId="";
var categoryNode = $(response).find("category > title");
var categoryTitle = $(categoryNode).text();
$("#category-title").html("<p>More in the "+categoryTitle+" category</p>");
$(response).find("board > id").each(function () {
boardId = $(this).text();
var boardTitle = $(response).find("board > title:eq("+index+")");
var otherBoardsList = $(boardTitle).text();
$("#Other-Boards-List").append("<ul><li><a href='"+"/t5/board/bd-p/"+boardId+"'>"+otherBoardsList+"</a></li></ul>");
index++;
});
},
error: function (response) {
$('#Other-Boards-List').html('Failed to load the content');
}
});
});
</script>
<div id="Other-Boards-List">
<div id="category-title"></div>
<p style="font-size:18px;">Browse other boards</p>
</div>