I am trying to receive JSON data (listSize
, MyList
) from the server by Ajax
on the client side. I don't know if this is applicable or not. the ajax part is not working in my code.
here it is
function createList(startIndex,endIndex){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
var myVar = '<%=request.getAttribute("objKey")%>';
var myObj = eval('(' + myVar + ')');
myObj.listSize = endIndex;
for (i = startIndex; i < myObj.listSize; i++) {
$('body').append('<div id="div'+ i +'" />');
$('#div' + i).append(myObj.MyList[i]);
}
}
};
xhttp.open("GET", "ServerSide.java", true);
xhttp.send();
}