Answer the question
In order to leave comments, you need to log in
How to display the necessary json elements (variables) on the front end (javascript)?
Good day!
I really need help ....
Here is such a js code
var userName = "name";
var passWord = "pass";
function authenticateUser(user, password)
{
var token = user + ":" + password;
var hash = btoa(token);
return "Basic " + hash;
}
function CallWebAPI() {
(код html <div>
<div id="response">
</div>
<input type="button" class="btn btn-primary" value="Call Web API" onclick="javascript:CallWebAPI();" />)
var request = new XMLHttpRequest();
request.open("GET", URL, false);
request.setRequestHeader("Authorization", authenticateUser(userName, passWord));
request.send();
// view request status
alert(request.status);
response = request.responseText;
console.log(response);
}
var some = document.getElementById("some");
some.innerHTML = response.name json variable;
or$("#some").text(response[0].name json variable + "\n" );
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question