【发布时间】:2014-01-16 09:30:46
【问题描述】:
我从助手类中的 bean 中获得 JSONOject。
内部助手
public JSONObject init() throws Exception{
// initializations codes are here
JSONObject json = JSONObject.fromObject(bean);
return json;
}
然后我需要在加载jsp时通过ajax请求访问jsp调用内部的JSONObject(分配如下的javascript变量)
jsp内部
$(document).ready(function(){
var VAR_JSON = // need to get the JSON through AJAX
});
以前我有这样的代码。
<script type="text/javascript">
var VAR_JSON = <%=helper.init()%>
</script>
如何通过 AJAX 实现这一点?
提前谢谢..!!
【问题讨论】:
-
尝试 $.ajax 和
json选项和url:"<%=helper.init()%>"api.jquery.com/jquery.ajax