-4

I echo a whole table to the div and then I can't access the id of it by some reason via jquery, what should I do?

I don't know how to ajax the datatable so I echo the whole table with post and it all work fine.

No error just can't access ID of button In the table I echo

I don't know what line of code I should provide here because everything work fine except I can't access the id of the button in the datatable that I echo from fetch.php to index.php

I checked with inspect mode and the ID are there with everything (ex. $(#'PROID112').click(function() ) <- the id of the buttons was all in place

Solution: I fixed it myself by changing

$('#id').click(function())

to

$(document).on('click', '#id', function()

thank you everyone for your answer ;)

  • alright, I removed the repeat sentence, please answer my question ;) and I don't know what to learn there because it might not relate to jquery so I try asking question here. – Pongsiri Tonsuk Aug 07 '19 at 16:42

2 Answers2

0

try document.getElementById("div_id").load(); or $.get(); at the end of the function (and before return true/false; if used) if that doesn't work then try with the function that inserts the data into the <div> outside of $(document).ready(function(){}); also since there is no code sample of the function to know what you are using, check you are not using .text() to load the data, use .html() instead to tell the browser its html and not just text or .load(url) to load the url data directly into the div.

Jou M.
  • 21
  • 4
0

write jquery code inside the success function after the table code it will be accessible

success:function(){
    //your table code

    $('$id').html();     ///or whatever you want to do 
}
}