javascript - Closing json data populated table -
I am trying to delete the existing table in a div and each time the page gets json encoding data Is
Do I Have Problems Closing the Table?
html:
& lt; Div id = "tblcontent" & gt; & Lt; / Div & gt; jq:
var um_getallusers = '& lt; Table class = "table-hover" id = "um" & gt; & Lt; Thead & gt; & Lt; Tr & gt; & Lt; th class = "col-md-1" & gt; Id & lt; / Th & gt; & Lt; th class = "col-md-4" & gt; Name & lt; / Th & gt; & Lt; th class = "col-md-4" & gt; Username & lt; / Th & gt; & Lt; th class = "col-md-3" & gt; & Lt; / Th & gt; & Lt; / Tr & gt; & Lt; / Thead & gt; & Lt; Tbody & gt; '; $ .getJSON ('php / um_getallusers.php', function (DTA) {$ ("# tblContent"). Remove (); // Dell table $ .each (dta, function (index, item) {um_getallusers + = ' & Lt; / tr & gt; & lt; TD & gt; '+ item.id +' & lt; / td> & lt; td & gt; '+ item.name +' & lt; / td & gt; ; & Lt; TD & gt; '+ item.username +' ';}); var um_getallusers =' & lt; ; / Table & gt; & lt; / table & gt; '; // This is my problem $ (' # um '). Html (um_getallusers);});
You are redefining the variable um_getallusers Already using it, plus you using instead of um_getallusers + to um_getallusers = '. var um_getallusers = '& lt; Table class = "table-hover" id = "um" & gt; & Lt; Thead & gt; & Lt; Tr & gt; & Lt; Th class = "col-md-1" & gt; Id & lt; / Th & gt; & Lt; th class = "col-md-4" & gt; Name & lt; / Th & gt; & Lt; th class = "colonel-MD-4" & gt; Username & lt; / Th & gt; & Lt; th class = "col-md-3" & gt; & Lt; / Th & gt; & Lt; / Tr & gt; & Lt; / Thead & gt; & Lt; TDA & gt; '$ .getJSON (' php / um_getallusers.php ', function (DTA) {$ ("# TBL content"). Remove (); // dell table $ .ee (dta, function (index, item) {Um_getallusers + = '<& Lt; td>' + item.id + '& lt; / td> & lt; td>' + item.name + '& lt; / td & Gt; & lt; TD & gt; '+ item.username +' & lt; / tr & gt; ';}); um_getallusers + =' & lt; / tbody & gt; & Lt; / table & gt; & lt; / table & gt; '; // This is my problem $ (' # um '). Html (um_getallusers);}); Then, remove the extra var and enter a +
Comments
Post a Comment