$(document).ready(function() {
var path = null;
console.log('${pageContext.request.contextPath}/loadfile');
$.ajax({
dataType: "json",
url: '${pageContext.request.contextPath}/loadfile',
success: function(data){
$.each(data,function(index,obj){
console.log(obj.id);
alert('inside');
path = obj.path;
});
}
});
ここで /loadfile は json オブジェクトを返す URL です。この URL に移動すると、HTML ページに印刷された JSON オブジェクトを見ることができますが、上記の JavaScript コードを含むページにアクセスしても同じ結果は得られません。