[SOLVED] Remove old result - Ajax - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: [SOLVED] Remove old result - Ajax (/showthread.php?tid=70430) |
[SOLVED] Remove old result - Ajax - googlemy - 04-08-2018 Hi CI Team, I very need your help to fix this, 1.How to remove old result when I click another category? 2.How to show all categories without click "All Categories" ? Please help me.... View: PHP Code: <a class="nav-link active" onclick="product_category(''); return false;" id="tab-all" data-toggle="tab" href="#tab-all" role="tab">All Categories</a> Controller: PHP Code: function getValues($id=''){ Model: PHP Code: public function get_product_by_category($id = '') RE: Remove old result - Ajax - jreklund - 04-08-2018 1. Empty #category before appending data PHP Code: var len = data.results.length; Code: product_category(''); RE: Remove old result - Ajax - theedo - 04-08-2018 You can remove all elements inside the div using $("#category").empty(); . So when your PHP send data to ajax call, the first thing is PHP Code: $("#category").empty();. To show all categories you can do it maybe static. So you can do a foreach like that: PHP Code: <div class="row justify-content-center" id="category"> This should work RE: Remove old result - Ajax - googlemy - 04-08-2018 Thanks you so much jreklund! also theedo.... thanks Problem solved! RE: Remove old result - Ajax - InsiteFX - 04-08-2018 Please edit your forum topic and add [SOLVED] to the Title. |