【发布时间】:2015-05-01 12:17:55
【问题描述】:
我刚刚实现了需要 AJAX 调用来检索访问令牌的 Google OAuth 混合服务器端流程。在我进行 AJAX 调用(存储令牌等)之后,我希望服务器使用名为 home.scala.html 的文件显示一些内容。
//called when client has confirmed the OAuth Login dialog
function signInCallback(authResult) {
if (authResult['code']) {
$.ajax({
url: "http://localhost:9000/storeauthcode",
...
success: function(result) {
//access token was saved
//now redirect to the home area of the website
window.location.replace("http://localhost:9000/home");
},
error: function (xhr, status, error) {
//handle error appropriately here
...
}
});
}
}
但是,如果我获得令牌并且一切正常,我会看到我的 home.scala.html 文件的模板代码(因此它会打印 html 标记),但不会将其解释为应该由浏览器呈现的 Html .
如何让浏览器将 home.scala.html 文件呈现为 Html 文件而不是纯文本?
PS:在这里进行重定向是否有意义,或者内容应该显示在同一页面上?当 Google 登录窗口关闭并且用户必须等到他被重定向到实际站点时,看起来有点奇怪。
我应该如何获取这些内容(AJAX、AngularJS)?
【问题讨论】:
标签: javascript ajax scala playframework playframework-2.3