我必须将此变量作为另一个函数的参数来调用,但由于无法返回,因此似乎无法执行此操作。我该怎么办?
function Getthisvarible()
{
var thisvariable;
var Request = new XMLHttpRequest();
var input = document.getElementById("SearchBox").value;
var url = "urlstring"
Request.open("GET",url,true);
Request.setRequestHeader("Authorization", "Bearer <apikey>");
Request.setRequestHeader("Accept", "application/vnd.api+json");
Request.send();
Request.onreadystatechange = function () {
if (this.readyState == 4) {
var jsonparsed = JSON.parse(Request.responseText);
var thisvariable = jsonparsed.data[0];
}
}
return thisvariable;
}
function Usethisvariable(somevariable)
{}
Usethisvariable(Getthisvariable());