• Как на jQuery перехватить (провести) get-запрос по динамическому множеству ссылок?

    XXI_BEK
    @XXI_BEK Автор вопроса
    Студент
    function renderSearchTable(item) {
                return `<tr>
                                    <td><button type="button" class="btn btn-link" onclick="renderArticle(${item.id})">${item.title}</button></td>
                                    <td>${item.pivot.quantity}</td>
    
                        </tr>`
            }
    
            function renderArticle(id) {
                $.ajax( {
                    url: '/wiki/article/' + id,
                    method: 'GET',
                    data: {
                        id: id
                    },
                    success:function(response) {
                        console.log(response);
    
                        if(response) {
                            $("#articleTitle").val(response.title);
                            $("#articleLink").val(response.link)
                            $("#articleText").html(response.content);
                        }
                    },
                    error:function (response) {
                        console.log(response + "error");
                    }
                });
    
            }

    По сути использование button вместо href
    Ответ написан
    Комментировать