Answer the question
In order to leave comments, you need to log in
How to output information from JSON not as a string, but as a list?
Hello everyone, such a question, how to adjust the output of information from JSON not as a string, but as a list. And if it is at all possible, that it displays the values already in the format of a button that you can simply click on
function select_company()
{
var chbx_list = collect_checkboxes();
var amount = chbx_list.length;
console.log(chbx_list);
csrf_token = $('input[name="csrfmiddlewaretoken"]').val();
$.ajax({
url : "/blockchain/", // the endpoint убрать первыйс слуеш в случае неудачи
type : "POST", // http method
data : {chbx_amount : amount,
checks_list : chbx_list,
csrfmiddlewaretoken: csrf_token }, // data sent with the post request
success : function(json) {
// console.log(json);
document.getElementById('companies').innerHTML = json.companies.join(', ');
},
// handle a non-successful response
error : function(xhr,errmsg,err) {
console.log("error");
}
});
return false;
}
Answer the question
In order to leave comments, you need to log in
let lisString = "";
for (const company of json.companies) {
const li = `<li>${company}</li>`;
lisString+=li;
}
document.getElementById("companies").innerHTML = lisString;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question