我使用Jira,需要填充所选项目的用户列表。
<td><select id="projectsList" class="textFld" multiple="multiple"></select></td>
<td><select id="userList" class="textFld"multiple="multiple" ></select></td>
书面文字
$(document).ready(function(){ getAllProjectsList();
$("#projectsList").change(function() {
var projKey = $("#projectsList").val();
if (projKey.length > 0) {
getAllUsersList(projKey);
}
});
});
function getAllProjectsList() { $.ajax({
type : "GET",
url : "http://server/issues/rest/api/2/project",
success: function(projectsList){
var htmlContent = '<option value="">Select-One</option>';
$.each(projectsList, function(index, item) {
htmlContent += '<option value="' + item.key + '">' + item.key + '</option>';
});
$("#projectsList").html(htmlContent);
}
}); }
我从server获得了所有项目的列表。现在我需要获得所选项目[多项目]的所有用户列表。
function getAllUsersList(projKey) { var proj= $("#projectsList option:selected").text();$.ajax({
type : "GET",
path : "http:/server/issues/rest/api/2/user/assignable/search?jql=project=proj AND startAt=0 AND maxResults=500 AND username=%",
contentType: "application/json;charset=utf-8",
dataType: "text",
success: function(userList){
var htmlContent = '<option value="">Select-One</option>';
$.each(userList, function(index, item){
var userId = item.UserID;
htmlContent += '<option value="' + item.key + '">' + item.key + '</option>';
});
$("#userList").html(htmlContent);
} }); }
将列表视为未定义...... 任何帮助.. ??
答案 0 :(得分:0)
我们可以传递查询字符串参数。用户列表正在工作。
function getAllUsersList(projectKey) { $.ajax({
type : 'GET',url: 'http://server/issues/rest/api/2/user/assignable/search?project='+projectKey+'&startat=0&maxresults=500&username=%',
success: function(userList){
var htmlContent = '<option value="">Select-One</option>';
$.each(userList, function(index, item){
var userId = item.UserID;
htmlContent += '<option value="' + item.key + '">' + item.key + '</option>';
});
$("#userList").html(htmlContent);
}
}); }