[Django]-JQuery ajax get API request append element to correct div

3👍

Set a class thats the same for each button:

<button class="myEvent" id="{{item.9}}"><i class="icon-bubble"></i> {{item.7}} </button>

$('.myEvent').on("click",function(e){
    e.preventDefault();
    $.getJSON("data.json", function(data) {
    //Handle my response

    });

});

with this solution you get the entire json file not filtered by “item”. the filter process ve to be done inside the function.

hope this help

Leave a comment