ziedinjsh Posted September 17, 2012 Report Share Posted September 17, 2012 Sveiki. Man te tāda interesanta lieta. Es ar jQuery .load() funkciju // ielādē komentārus jQuery(function($) { jQuery('#show_comments').html('<center><img src="img/loading.gif"/></center>'); jQuery('#show_comments').load('show_comments.php'); }); ielādēju komentārus <?php include('process/dbase.php'); $id = isset($_GET['id']) ? $_GET['id'] : ''; $comment = mysql_query("select * from comments where aid='$id' order by id desc") or die(mysql_error()); while($data = mysql_fetch_array($comment)){ echo ' <div class="commentWarp"> <div class="cNick">@ '.$data['author'].'</div> <div class="cComment">'.$data['comment'].'</div> <div class="cBottom">'.$data['date'].'</div> </div> '; } ?> Lieta tāda, ka jQuery savu funkciju izpild (pārbaudiju ar alert();), bet komentārus neparāda. Includojot php failu iekš div komentārus parāda. Kāds iepesls varētu būt ka jQuery it kā ielādē failu, bet nerāda faila saturu? Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted September 17, 2012 Report Share Posted September 17, 2012 Tāds, ka tabulā noteikti nav komentāru, kuriem aid == '' Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 17, 2012 Author Report Share Posted September 17, 2012 includojot php failu, komentāri rādās. Drīzāk ka tas $_GET netiek padots, hmm Quote Link to comment Share on other sites More sharing options...
reiniger Posted September 17, 2012 Report Share Posted September 17, 2012 jQuery('#show_comments').load('show_comments.php',{id: '<?=$id?>'}); Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 17, 2012 Author Report Share Posted September 17, 2012 tad man tas jQuery kods jāliek tai pašā lapā kur tiek izvadīts id Quote Link to comment Share on other sites More sharing options...
daGrevis Posted September 17, 2012 Report Share Posted September 17, 2012 Nevajag jaukt kopā ar PHP! Nu nevajag! Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 17, 2012 Author Report Share Posted September 17, 2012 nu iekš js faila ieliku, bet nu nestrādā Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted September 17, 2012 Author Report Share Posted September 17, 2012 neiebraucu ar $.ajax. Mēģināju šādi: Html <div id="show_comments" class="30"></div> jQuery jQuery(function($) { var id = $('#show_comments').attr('class'); jQuery('#show_comments').html('<center><img src="img/loading.gif"/></center>'); jQuery('#show_comments').load('show_comments.php?id=id'); }); clasi nolasa (pārbaudija ar alert();) bet failā viņš neatver. Ieliekot iekš php ?id=id vietā ?id=$id atvēra Quote Link to comment Share on other sites More sharing options...
Kemito Posted September 19, 2012 Report Share Posted September 19, 2012 Kamdēļ vispār likt komentāra id nummuru klasē? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.