我正在编写一个javascript代码,但是我也觉得我的代码质量不是那么干净,而且我也遇到了问题,实际上我正在使用两个函数,一个是getcategory(),另一个是getproblem()< / p>
我希望先执行getcategory函数,然后再将getproblem()作为第二个函数执行
控制台当前正在显示什么
Actual Result : Thank you
abc
我要在控制台中显示的内容
Excepted Result : abc
Thank you
var Defectid;
var projectAreaContextId;
$(document).ready(function() {
Defectid = "222222";
//On Load : Fetching Project Area UUID Dynamically from Rest Url
function makeAjaxCall(url, methodType, callback) {
return $.ajax({
url: url,
method: methodType,
dataType: "xml"
})
}
var formRESTURL = fetchUrlOrigin + "/ccm/rpt/repository/workitem?fields=workitem/projectArea[name=" + actualPA + "]/(contextId)";
makeAjaxCall(formRESTURL, "GET").then(function(xmlResponse) {
var PA = $(xmlResponse).find('projectArea');
$(PA).each(function() {
var name = $(this).find('contextId').text()
if (ServerUrl.includes(templink)) {
projectAreaContextId = name;
}
});
//On Load : Fetching the category
fetchCategories(projectAreaContextId)
//On Load: Fetching ProblemID and FiledAgainst Automatically
getProblem(DefectID, projectAreaContextId)
}, function(reason) {
});
fetchcategory(projectAreaContextId) {
console.log("value is " + abc);
}
getProblem(DefectID, projectAreaContextId) {
console.log("Thank you ");
}