Answer the question
In order to leave comments, you need to log in
Through the function I receive JSON and I need to draw it and bind it to the buttons, how to do this?
Through this function I get JSON
function GetServices(type,region_id,group_id)
{
jQuery.ajax({
method: "POST",
url:"",
data:"?®ion_id="+region_id+"&type="+type+"&group_id="+group_id,
success: function (html){
var obj = JSON.parse(html);
jQuery("#temp").html("");
jQuery.each(obj, function(index, value) {
jQuery("#temp").append("service_id:"+service_id+", name:"+value.name+"");
});
}
});
}
Answer the question
In order to leave comments, you need to log in
DDias , in this case, you need to create an event handler (Event) on the buttons. In this case, the "click" event will probably suit you.
// находим на сайте ссылку на кнопку
const button1 = document.querySelector('CSS-селектор на кнопку');
// делаем обработчик события
button1.addEventListener('click', function(e) {
console.log('Случилось событие клик на кнопку');
// тут делаем всё что касаеться "привязки"
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question