[英]How can i generate ajax url from external javascript file in play framework?
I use the "jsAction" tag to generate ajax url in play framework: 我使用“ jsAction”标签在播放框架中生成ajax网址:
var addToFriendURL = #{jsAction @users.addToFriend(':friendId') /}
The code works fine in html template inside a tag,but i found it's invalid in a external javascript file which i include in the html template. 该代码在标记内的html模板中工作正常,但我发现它在html模板中包含的外部javascript文件中无效。
What was happened when i move the code to a external javascript file ? 将代码移至外部javascript文件时发生了什么情况?
Once it is moved to javascript file, it becomes statically served content that the Play server does not parse. 将其移至javascript文件后,它将成为Play服务器无法解析的静态提供的内容。 Therefore, you have a few options
因此,您有几种选择
Personally I would go with option 2, but it may depend on your requirements. 我个人会选择选项2,但这可能取决于您的要求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.