sniperscope Posted August 23, 2011 Share Posted August 23, 2011 Hi I have some problem with ajax. My script connect query page but doesn't return any value. Regards Note: In same page DELETE function works fine but not display. Here is my index.php: <script type="text/javascript"> $(function() { $(".showme").click(function() { var commentContainer = $(this).parent(); var id = $(this).attr("imd"); var string = 'id='+ id ; $.ajax({ type: "POST", url: "sql/reservation.php", data: string, cache: false, success: function() { $('#ajaxDiv').html(data); } }); }); }); </script> <?php while($ROW = mysql_fetch_array($SQL)) { echo '<li style="text-align:right; width:100%;">' .$i; if($ROW['is_read'] == 0) echo ' <img src="images/email_unread.png" /> '; else echo ' <img src="images/email_read.png" /> '; echo '<a href="#" imd="' .$ROW['id']. '" class="showme">'. date("Y-n-d H:i", $ROW['RegDate']).'</a>'; $i++; } ?> <div class="ajaxDiv" id="ajaxDiv"></div> And this is reservation.php: <?php include('../inc/cn.php'); $SQL = "SELECT * FROM reservation WHERE id = '" .$_POST['id']. "' LIMIT 1"; $SQL = mysql_query($SQL); $ROW = mysql_fetch_array($SQL); // Test purpose to see that if ajax connect this page or not. // $fp = fopen("sql.txt", 'a'); // fwrite($fp, $SQL); // fclose($fp); echo '<table width="100%" cellpadding="3" cellspacing="1" border="0" bgcolor="#000000"> <tr><td><table width="100%" border="0" cellspacing="1" cellpadding="4" bgcolor="#999999"> <tr><td width="100" bgcolor="#FFFFE5">name</td><td bgcolor="#FFFFFF">' .$ROW['Name']. '</td></tr> <tr><td bgcolor="#FFFFE5">date</td><td bgcolor="#FFFFFF">' .$ROW['resDate']. '</td></tr> <tr><td bgcolor="#FFFFE5">user id</td><td bgcolor="#FFFFFF">' .$ROW['memID']. ' '; if($ROW['is_new'] == 1) echo '<span style="font-weight:bold; color:red;">new user</span>'; echo '</td></tr> <tr><td bgcolor="#FFFFE5">email add</td><td bgcolor="#FFFFFF"><a href="mailto:' .$ROW['memMail']. '">' .$ROW['memMail']. '</a></td></tr> <tr><td bgcolor="#FFFFE5">phone</td><td bgcolor="#FFFFFF">' .$ROW['memPhone']. '</td></tr> <tr><td bgcolor="#FFFFE5">remarks</td><td bgcolor="#FFFFFF">' .nl2br($ROW['memQuest']). '</td></tr></table> </td></tr> </table>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245477-ajax-doesnt-return-value/ Share on other sites More sharing options...
Alex Posted August 23, 2011 Share Posted August 23, 2011 A quick glance shows that you're forgetting to pass the data parameter into the callback, success: function() { $('#ajaxDiv').html(data); } Should be: success: function(data) { $('#ajaxDiv').html(data); } Quote Link to comment https://forums.phpfreaks.com/topic/245477-ajax-doesnt-return-value/#findComment-1260824 Share on other sites More sharing options...
sniperscope Posted August 23, 2011 Author Share Posted August 23, 2011 wow Alex you are wonderful. Thank you soooooooooooooooo much. it works now. Quote Link to comment https://forums.phpfreaks.com/topic/245477-ajax-doesnt-return-value/#findComment-1260825 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.