Frisbetarian Posted December 27, 2012 Share Posted December 27, 2012 (edited) Hey all so Im trying to put data through an AJAX call into this div <div class="scroll-pane2 blue small" style=""> <p id="bulletinBodyArea" style="margin-right:20px;"></p> </div> The AJAX is being triggered when one clicks on one of the links being fed from the database <div class="bulletinSectionAccordion rounded"> <p class="blue" style="font-size:19px;margin-left:23px;margin-top:15px;margin-bottom:10px;">Archives</p> <?php $query = "SELECT * FROM `bulletin` LEFT JOIN `bulletininschool` ON `bulletin`.`id`=`bulletininschool`.`bulletin` WHERE `school` = 2 "; $result=$connection->query($query); while($row = $result->fetch_array()) { echo '<p class="medium titi" style="margin-left:23px;">'.$row['title'].'</p>'; } ?> </div> It gets called and then passes the data $(".titi").click( getBody ); function getBody(){ $("#bulletinBodyArea").load('update/getBody.php'); }; And this is the AJAX function <?php $section='bulletin'; $table="bulletin"; $schoolSelectorTable="bulletininschool"; $schoolSelector="bulletin"; $db_host = "localhost"; $db_user = "root"; $db_pass = ""; $db_name = "isl"; mysql_connect($db_host, $db_user, $db_pass, $db_name); mysql_select_db("isl") or die(mysql_error()); $states = mysql_query("SELECT * FROM `bulletin` LEFT JOIN `bulletininschool` ON `bulletin`.`id`=`bulletininschool`.`bulletin` WHERE `school` = 2" ); while($state = mysql_fetch_array($states)){ echo "<p>".$state['body']."</p>"; } ?> Now the links that one clicks that are fed from the database are actually article titles, and when one clicks on a specific title the AJAX call should go and fetch the body text associated with that article. But I'm having trouble understanding how I should go through that. I'm doing the correct queries and getting the titles and the bodies but I just cant figure out how to associate them. Do I pass a variable to the AJAX call? Thank you Edited December 27, 2012 by Frisbetarian Quote Link to comment https://forums.phpfreaks.com/topic/272406-passing-php-data-through-an-ajax-call/ Share on other sites More sharing options...
trq Posted December 27, 2012 Share Posted December 27, 2012 Indeed you need to pass a variable along with the Ajax request. Quote Link to comment https://forums.phpfreaks.com/topic/272406-passing-php-data-through-an-ajax-call/#findComment-1401488 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.