From a JavaScript file I call a PHP script through Ajax. The PHP returns an echo with a table. Something like this:
echo "<tr><td id=\"something\">$value<\td><\tr>";
This works fine. But now i want to target the cell with id "something". that i cannot do because JavaScript does not recognize the id because it was already loaded before i did the call to PHP. i tried reloading my javascriptfile after calling the php file. Than it finds the id but it runs all my other scripts twice (i think because the javascript file loaded twice and do not replace the old one).
Is there a way to target this id without reloading the javascript file again. P.s. i reloaded the javascript file as part of the php file. At the end of the php file i put put something like this:
echo "<script type=\"text/javascript\" src=\"js/javaScriptfile.js\"></script>";
The php script looks like this:
echo "<tr><td>Persmachine appels</td><td id=\"capaciteitPersmachineAppelsBeginRonde\">$capaciteitPersmachineAppelsBeginRonde</td><td id=\"uitbreidenPersmachineAppels\">$uitbreidenPersmachineAppels</td><td id=\"actueleCapaciteitPersmachineAppels\">$actueleCapaciteitPermachineAppels</td><td id=\"capaciteitPersmachineAppelsPerStap\">$capaciteitPenSMachineAppelsPerStap</td><td id=\"kostenPersmachineAppelsPerStap\">$kostenUitbreidingPenSMachineAppelsPerStap</td><td><button class=\"btn btn-default\" id=\"BTNpersmachineAppelsPlus\"><img src=\"Graphics\PlusIcon.png\" width=\"20\" /></button><button class=\"btn btn-default\" id=\"BTNpersmachineAppelsMin\"><img src=\"Graphics\minIcon.png\" width=\"20\" /></button></td><td id=\"nieuweCapaciteitPersmachineAppels\">$actueleCapaciteitPermachineAppels</td></tr>";
The AJAX call looks like this:
$.ajax({
url:'http://12dobec.nl/JFC/php/huidigeStatusPerCategorieDownloadenV2.php',
data:{klas:klas, team:team, gekozenOverzicht:gekozenOverzicht},
type: "GET",
success: function(data){
$('#BeslissingenFabriek').html(data);
}});
As you can see i alse put two buttons into the php echo. I cannot target them too. Again i think because the javascript file loaded before. When load the javascript again it finds everything but then scripts runs twice.