如何将 JSON 从 wicket 传递到 JavaScript?
我在java脚本页面中有以下函数调用wicket ajax:
function callWicketPage() {
wicketAjaxGet(
urlCallback,
function() {alert('success'); },
function() { alert('failed');
});
}
并且在wicket页面中我执行以下操作:
final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() {
@Override
public void renderHead(IHeaderResponse ihr) {
super.renderHead(ihr);
ihr.renderJavascript("var urlCallback = '" + this.getCallbackUrl() + "';", "insertedjavascript");
}
protected void respond(final AjaxRequestTarget target) {
}
};
add(behave);
我想要的是将json响应从wicket页面发送回JavaScript,我该怎么做\?
I have the following function in java script page that call wicket ajax:
function callWicketPage() {
wicketAjaxGet(
urlCallback,
function() {alert('success'); },
function() { alert('failed');
});
}
and in the wicket page I do the following:
final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() {
@Override
public void renderHead(IHeaderResponse ihr) {
super.renderHead(ihr);
ihr.renderJavascript("var urlCallback = '" + this.getCallbackUrl() + "';", "insertedjavascript");
}
protected void respond(final AjaxRequestTarget target) {
}
};
add(behave);
What i want is to send back a json response from the wicket page to JavaScript, How could i do it \?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您改用
ResourceReference
,这样您就不必获得对页面实例的读/写访问权限(并安装它以便从客户端脚本更轻松地访问)。但如果你想保留基于行为的解决方案:
i would suggest you to use a
ResourceReference
instead, so you don't have to get read/write access to page instance (and mount it for easier access from your client side script).But if you want to keep your behavior based solution: