来自 Velocity 模板的 AJAX 调用
我有一个测试网页,它使用 jQuery 和 AJAX 调用 ASMX Web 服务并返回 JSON 格式的客户列表。然后返回的数据将填充标签的自动完成列表。在测试环境中一切正常。我现在尝试在 JIRA 中使用相同的代码,以便我可以使用 AJAX 调用将返回的客户列表填充自定义字段,但是 AJAX 调用不起作用。在我的速度模板文件中,我有以下用于 AJAX 调用的代码:
<script>
jQuery("#customfield_10000").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
url: "http://myserver/jiraservice/ajaxservice.asmx/GetCustomers",
cache: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{inputValue:\"" + request.term + "\"}",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item,
value: item
}
}));
}
});
},
minLength: 2
});
</script>
如果有人可以指出如何从 Velocity 模板正确执行 AJAX 调用,那就太好了。
提前致谢!
I have a test webpage which uses jQuery and AJAX to call an ASMX webservice and returns a list of customers in JSON format. The returned data then populates an autocomplete list for an tag. In the test environment everything works perfectly. I am now trying to get the same code working in JIRA so i can populate a customfield with the list of customers the AJAX call will return, however the AJAX call doesn't work. In my velocity template file i have the following code for the AJAX call:
<script>
jQuery("#customfield_10000").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
url: "http://myserver/jiraservice/ajaxservice.asmx/GetCustomers",
cache: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{inputValue:\"" + request.term + "\"}",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item,
value: item
}
}));
}
});
},
minLength: 2
});
</script>
If someone could please point out how to properly perform an AJAX call from a Velocity template, that would be great.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通常使用这种代码:
然后确保 atlassian-plugin.xml 中存在 AJS
问题选项卡使用的 JavaScript 和 CSS 文件。
并确保使用 WebResourceManager 包含资源
I usually do it using this kind of code:
and then make sure that AJS exists with this in atlassian-plugin.xml
JavaScript and CSS files used by Issue Tabs.
and make sure that resource gets included using a WebResourceManager