`element.innerHTML` not working as expected

98
March 06, 2022, at 6:30 PM

I have a form on whose submission, will post a URL, and the server returns a HTML string which should be appended to the form.

Sometimes it replaces the HTML content of the element with the new one but sometimes it replaces only few part of the HTML content received from the server.

I have tried $(document.getElementById(element).html() and document.getElementById(element).innerHTML = "" but both are working as same sometime it append the value but sometimes it does only a few part of it.

Test it with a YouTube url....

$('input[type="button"]').click(function () {
    $('.login').addClass('test')
    setTimeout(function () {
        $('.login').addClass('testtwo')
    }, 300);
    setTimeout(function () {
        $(".authent").show().animate({
            right: -320
        }, {
            easing: 'easeOutQuint',
            duration: 600,
            queue: false
        });
        $(".authent").animate({
            opacity: 1
        }, {
            duration: 200,
            queue: false
        }).addClass('visible');
    }, 500);
    var form = $('#download_video');
    jQuery.ajax({
        url: 'https://testuia.herokuapp.com/formats',
        method: 'POST',
        data: form.serialize()
    }).done(function (response) {
        if (response.success == true) {
            console.log(response.results);
            const formats = response.results;
            show_formats(formats);
        } else {
            document.getElementById('formats').innerHTML = response.error;
        };
    }).fail(function () {
        alert("	
Rent Charter Buses Company
READ ALSO
How to call method Model in jQyery

How to call method Model in jQyery

I have a path method in the Course model

112
Jquery data tables need to show only selected rows from an integer array of IDs

Jquery data tables need to show only selected rows from an integer array of IDs

I have a drop down with checkboxes in itWhen I select multiple items, I have a method which gets those IDs in an integer array

125
Append value to ckeditor 5 in textarea jquery in modal

Append value to ckeditor 5 in textarea jquery in modal

In a bootstrap 4 modal is located a form with a textarea using CKEditor 5This form is for updating data from a database

129