how to add content to html tables using javascript

111
November 30, 2018, at 3:20 PM

I am designing a web application where I need to fetch the data from the server and should display it in table, which had a search functionality. When I hardcode the data in tables the search is working fine, but when i append the data fetched from the server using JavaScript innerhtml or jQuery append methods the search is not working.

Note: I have tried fetching the data using PHP, then the search is working fine because the html is rendered on the server. Is there any way which adds the data to the html as a static page by fetching from server using jQuery or JavaScript ?

Answer 1

If you are using AJAX request then you can use any of following

$("loadData").append("<b>Appended text</b>");

or

$('#loadData').html("<div id='content'></div>");

or

var contentDiv=$("<div id='content'></div>");
$('#loadData').append(contentDiv);
Answer 2

if you are using jQuery $.ajax for fetching the data, write the search function inside the success function of $.ajax

$.ajax({
    success: function (response) {
        append the data in the table
        // move your search function here
        function searchTable(){}
    }
});
READ ALSO
PHP - Get value from saved dropdown

PHP - Get value from saved dropdown

I have a plugin in Wordpress in wich i can make custom field like dropdown etcNow I need to get the saved value from the dropdown

117
Why do i get array foreach loop?

Why do i get array foreach loop?

Hello can someone explain me why i'm getting an array in this code?

194
Fetch all images from dir and sort two by two using php

Fetch all images from dir and sort two by two using php

I have a slider where I show two vertical images (image reference) at once and am using slick slide to use a slider - it works fine, but I am now trying to code something that will enable me to just specify in the database what folder to pick the images...

122
Make the dialogflow that is integrated to messenger send an announcement to all users

Make the dialogflow that is integrated to messenger send an announcement to all users

How to make my chatbot which is made in dialogflow and integrated in messenger , send an announcement to all of it's users

79