javascript - HTML tables with different ID's are receiving sames value form AJAX callback -
this problem has driven me crazy!! here situation, have callback data ajax post method need pass different html table there 7 different tables. have achieve receive data controller different objects.earlier today have made first table working great, when want pass value different table different data again ajax callback data both table receiving same value if id' different if there no id on second one... have driven me crazy.
here ajax post method callback data:
$(document).ready( function() { $('#call_back_btn').click(function() { $.post("/app_dev.php/ajaxsearch", { person_name: $('#input_text').val() }, function(data) { objconnectors = data[0]; objcontacts = data[1]; var parseconnector = json.parse(objconnectors); var parsecontacts = json.parse(objcontacts); var cycles; (cycles = 0; cycles < parseconnector.length; cycles++) { $('tbodyconnector').append('<tr>' + parseconnector[cycles].id + '</td><td>' + parseconnector[cycles].n_c + '</td><td>' + parseconnector[cycles].description + '</td></tr>'); } (cycles = 0; cycles < parsecontacts.length; cycles++) { $('tbodycontact').append('<tr>' + parsecontacts[cycles].id + '</td><td>' + parsecontacts[cycles].n_c + '</td><td>' + parsecontacts[cycles].description + '</td></tr>'); } }
as can see there appends different
here html :
div class="bs-example" data-example-id="panel-without-body-with-table"> <div class="panel panel-default"> <div class="panel-heading">available connectors</div> <table id="connectors"> <thead> <tr> <th>12nc</th> <th>description</th> </tr> </thead> <tbody id="tbodyconnector"> </tbody> </table> </div> </div> <div class="bs-example" data-example-id="panel-without-body-with-table"> <div class="panel panel-default"> <div class="panel-heading">available contacts</div> <table id="contacts"> <thead> <tr> <th>12nc</th> <th>description</th> </tr> </thead> <tbody id="tbodycontact"> </tbody> </table> </div> </div>
here 2 tables. value first value so: parseconnector i'll highly appreciate help!!!
$('tbodyconnector').append("...");
and
$('tbodycontact').append("...");
are missing hash symbol.
try $('#tbodyconnector').append("...");
same goes tbodycontact
Comments
Post a Comment